✅  ❌ {{ user_message.number_answer }}

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.

1. Find a max element in the array.

You'll have to go through the whole array element by element.

2. Flip to the max element position.

Max element must be included in the flip.

3. Flip to the end.

The flip will move the max element to the end position.

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.

Start Chat