# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Sakib and Shamim are good friends. As Sakib is a little naughty, every night before exam he disturbs Shamim. One day Shamim got an idea to get rid of Sakib. Shamim gave him a sequence of parenthesis and bracket and told him to determine the maximum length of a valid sequence.

For example, [] , ([]) are valid sequence but (] [)(] are not. Remember an empty sequence is also a valid sequence. Since Sakib was intelligent he solved the problem easily and continued disturbing Shamim. Can you solve it too?

You will be given L (the length of the sequence) where L<=10^6 and the sequence will contain at least one character. You have to print the maximum length of a valid sequence.

Input | Output |
---|---|

[]() ([])() | 2 4 |

56% Solution Ratio

Fazlerabbi.Earliest,

Fazlerabbi.Fastest, 0.0s

Fazlerabbi.Lightest, 0 B

Fazlerabbi.Shortest, 778B

Login to submit