Need help in BRCKTS — Brackets(SPOJ)

Правка en1, от mohit_joshi, 2021-07-17 10:41:39

Problem Mysolution This approach is giving wrong answer. Can you please help me out in this question. My approach is something like:- (=+1; )=-1; Now I am just checking two conditions. 1.Is the overall sum of the segment is 0 or not because a balanced segment like (()) will be (+1+1-1-1)=0. 2.Now to avoid the conditions like )( , (( , I am checking whether the left child node of the 1st node is having sum>=0 and right child sum<=0.If this gets true , then answer is yes else no. Thanks in advance.

Теги #segment tree, merge segment tree, #help

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский mohit_joshi 2021-07-17 10:41:39 618 Initial revision (published)