Please help me as to how to approach this kind of problem. How can i think of using BFS here??
Question link: link text
BFS is used here to find shortest path between different states of array,
- Sort the array to get target array.
- now naively reverse all prefixes one by one and push them into queue (with each step cost as 1).