Given a string, say s="##$$$#"
, how can I find the index where the number of "#" symbols before the index is equal to the number of "$" symbols after the index?
Example: if s="##$$$#"
, then the output would be 2.
Explanation: before index 2 we have 2 "#" symbols and after index 2 we have 2 "$" symbols
I tried finding the mid index first and count the symbols(# and $) on both the sides,if they are equal then print the mid index else increment the mid and proceed the same way.. But I'm not able to get the logic correctly.