Pancake sorting simple solution.
Try to solve the problem by yourself before looking at the solution. You can chat with the Bot 🤖. He'll build your intuition step by step without giving you a straight answer.
You'll have to go through the whole array element by element.
Max element must be included in the flip.
The flip will move the max element to the end position.
But consider to find a max element in a shrinked array because current max is already placed in it's position. Flipping at the step 3 should work with the new end position too.