give array integer arr sort array perform series pancake flipsIn pancake flip follow stepschoose integer k 1 k arrlengthReverse subarray arr0k1 0indexedFor example arr 3214 perform pancake flip choose k 3 reverse subarray 321 arr 1234 pancake flip k 3Return array kvalue correspond sequence pancake flips sort arr any valid answer sort array 10 arrlength flip judge correct Example 1input arr 3241output 4243explanation we perform 4 pancake flips k value 4 2 4 3starting state arr 3 2 4 1after 1st flip k 4 arr 1 4 2 3after 2nd flip k 2 arr 4 1 2 3after 3rd flip k 4 arr 3 2 1 4after 4th flip k 3 arr 1 2 3 4 sortedexample 2input arr 123Output Explanation the input sort need flip anythingnote answer 3 3 accept Constraints1 arrlength 1001 arri arrlengthAll integers arr unique ie arr permutation integer 1 arrlength