medium Arrays 100 points

Missing Element in Array

Given an array of integers, determine the missing element in the sequence from 1 to n where n is the length of the array. If the array is not in ascending order or does not contain all integers from 1 to n, return -1. If the array contains all integers from 1 to n, return the length of the array. Example: Input: [4, 2, 3], Expected Output: 1.

Problem Description

Given an array of integers, determine the missing element in the sequence from 1 to n where n is the length of the array. If the array is not in ascending order or does not contain all integers from 1 to n, return -1. If the array contains all integers from 1 to n, return the length of the array. Example: Input: [4, 2, 3], Expected Output: 1.

Examples

Example

Input: [4, 2, 3]

Output: 1

Challenge Info

100 Points

Reward

medium

Difficulty

No limit

Time Limit

Submission Stats

Total Submissions 0
Accepted 0
Success Rate 0%