moves consists of the letters L and R, with equally many of each. Call a string even if it contains the same number of L and R letters.
Cut moves into consecutive non-empty pieces so that every piece is even and the number of pieces is as large as possible. Return that maximum number of pieces.moves='LRRLLR' → 3
Cut it into "LR", "RL", "LR": each piece has one L and one R.
moves='LLRRRL' → 2
"LLRR" and "RL". The first piece cannot be shorter: "LL" and "LLR" are not balanced.
moves='RRRLLL' → 1
moves='LRRLLR'
3
Run checks the first 3 tests in your browser. Submit checks all 77 tests on the server, hidden ones included.