a string valid parenthesis stre denote VPS consist character andIt string orIt write AB a concatenate B A b vps orit write a a VPSWe similarly define nesting depth depths VPS S followsdepth 0depthA B maxdepthA depthB a b vpssdepth a 1 depthA A VPSFor example VPSs nesting depth 0 1 2 vps give VPS seq split disjoint subsequence a B A b vps Alength Blength seqlengthnow choose a b maxdeptha depthb minimum possible valuereturn answer array length seqlength encodes choice A b answeri 0 seqi a answeri 1 note multiple answer exist return Example 1input seq output 011110example 2input seq Output 00011011 Constraints1 seqsize 10000