Round 1
Questions: An array is given. For example:
[-2, 4, 3, -2, -1]
In one operation, you can delete one element and then add the elements which are present to the left and right of it. You can also delete elements that are present at index 0 and the last index.
For example, let's say I am removing -2 at index 3:
- The array would be -2, 4, 2 (adding elements present at index 2 and 4).
- Now removing the element from index 0, the array would be 4, 2.
- Now removing the element from index 1, the array would be 4.
The final answer is 4.
So basically, repeat this operation until only one element is left. That would be your answer. Perform these operations in such a way that you get the maximum element as the answer.
Constraints:
- Size of the array could be 10^5
- -10^9 <= arr[i] <= 10^9
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.