JPMorgan ChaseOA #32
How Many Flips?
估计简单可在线判题
Start with an all-0 string of the same length. Each step picks one position and toggles 0/1 at that position and every position to its right. Find the minimum number of steps to obtain the target.
输入格式
The first line contains the length n, and the second line contains the binary target string; an empty string is written as an empty line. Original bounds: Unknown. This site uses 0≤n≤200000; the catalog's 100,000 bound is not original evidence.
输出格式
Output a single integer answer.
样例 1
输入:
5
01011
输出:
3
样例 2
输入:
0
输出:
0
样例 3
输入:
3
111
输出:
1
样例说明
The outputs of the three public examples are, in order: 3; 0; 1. These answers have been checked by independent enumeration or direct simulation.