Round 1
Questions: Given a permutation array consisting of values from 1 to N. 2 types of operations can be performed on the array:
- Swap any 2 elements at different indices.
- Rotate Left (can be used only once).
Find the minimum operations to sort the array.
Example:
-
arr = [3, 1, 2]
ans = 1
Explanation - rotate left once. -
arr = [5, 3, 2, 1, 4]
ans = 2
Explanation -- Rotate left -> arr becomes [3, 2, 1, 4, 5]
- Swap 1 and 3 -> arr = [1, 2, 3, 4, 5]
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.