leetle

Daily challenge for 2026-08-02

579. Pancake Flipper

You are given a string pancakes representing a stack of pancakes, where 'U' means the pancake is face-up and 'D' means it is face-down. You want to flip the pancakes one by one. Whenever you encounter a 'D', you flip it to 'U'. However, you can only flip a pancake if you have processed all pancakes before it. Return the total number of flips required to make all pancakes face-up. Since each 'D' requires exactly one flip and they don't affect each other in this simplified version, just count the number of 'D's.

Example:
Input: pancakes = "UUDUD"
Output: 2

Run this challenge interactively in Python or JavaScript when the app loads.