Find the irror ramu calculated the ixp ression -7-(-3) and came up with an answer -10-what did ramu do wrong ?
Answers
Answered by
0
Answer:
The idea is take value of open bracket ‘(‘ as 1 and value of close bracket ‘)’ as -1. Now start finding the prefix sum of the given string. The farthest index, say maxi, where the value of sum is 0 is the index upto which longest balanced prefix exists. So the answer would be maxi + 1.
Below is the implementation of this approach:
Similar questions
Math,
1 month ago
Math,
1 month ago
History,
1 month ago
Social Sciences,
3 months ago
Social Sciences,
3 months ago
Social Sciences,
9 months ago
English,
9 months ago
Math,
9 months ago