Sort Permutation
Problem Overview
- Determine for each query whether the permutation p can be sorted using exactly moves[i] swap operations, returning a binary string of results.
- Input: permutation p of 1..n and array moves of length q; one move swaps any two distinct indices. Output: a string of length q with '1' if possible, else '0'.
- Domain: array manipulation and permutations in practical sorting contexts.
- This is an Amazon interviews coding interview problem and a real interview question assessing move-based sorting feasibility.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
