The TransCompilator

Solved LeetCode program · 839 of 1,000

#1111 · Maximum Nesting Depth of Two Valid Parentheses Strings

Medium String chunk-17.md

Original English source

The sequence is "(()())". The answers is an empty list of whole numbers. The depth is 0. The last is the last position of sequence.
For every spot from 0 to last.
The symbol is the slice of sequence from spot to spot plus 1. If symbol matches "(", The opening is depth modulo 2, Place opening into answers, Add 1 to depth. If symbol matches ")", subtract 1 from depth. If symbol matches ")", The closing is depth modulo 2, Place closing into answers.

The parts is an empty list of text.
For each choice in answers.
The piece is format whole number choice as text. Place piece into parts.

The line is join parts with ",". Show line.

Open in Playground Browse all 1,000 problems

Expected stdout

0,1,1,1,1,0