Panda Guru LogoPanda
Guru

Swiggy | OA | Array Conversion

Round 1

Questions: Given a permutation array consisting of values from 1 to N. 2 types of operations can be performed on the array:

  1. Swap any 2 elements at different indices.
  2. 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:

  1. Rotate left -> arr becomes [3, 2, 1, 4, 5].
  2. Swap 1 and 3 -> arr = [1, 2, 3, 4, 5].
Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.