Bfs or any other method

Given a permutation of 1 to n, you need to perform some operations to make it into increasing order. Each operation is to reverse an interval a1,a2,…,ax(1≤x≤n) (a prefix). Your goal is to minimize the number of operations.

eg-
3
3 1 2
output
2
how to solve this problem using bfs or from any other method

3 Likes

thanks a lot…