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
Hindi,
2 months ago
Math,
2 months ago
Social Sciences,
4 months ago
Social Sciences,
4 months ago
Social Sciences,
10 months ago
English,
10 months ago
Math,
10 months ago