How to approach the problem- Permutation?

Please help me as to how to approach this kind of problem. How can i think of using BFS here??
Question link: link text

1 Like

BFS is used here to find shortest path between different states of array,

  1. Sort the array to get target array.
  2. now naively reverse all prefixes one by one and push them into queue (with each step cost as 1).

Solution