Counting Valleys

Read the lesson → understand the pattern → then code. Tutor works offline (built-in teacher); optional Cursor/Gemini keys upgrade chat quality.

Topic refresher: HackerRank Warmup

Classic warmup problems, taught slowly in Hindi, English, or Hinglish, then typed by you.

long long sum = 0;
for (int x : a) sum += x;
return sum;
HackerRank Warmup

Counting Valleys

Easy
HackerRank
12/12
EasyHackerRank Warmup

Counting Valleys

U is +1, D is -1. A valley is a step sequence that starts below sea level and returns to 0.

Examples

Example 1

Input

8
UDDDUDUU

Output

1

Stuck? Take a nudge

C++17