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.
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.
Example
Input: [4, 2, 3]
Output: 1