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.
4. Repeat step 1.
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.