You're given String which consists of open and close bracket, numbers and question mark (?). Also you're given two integer M and N. M is number of plus (+) and N is number of minus (-). You'll have to replace question mark (?) with plus (+) and minus (-) and maximize the expression. You'll have to use exactly M plus (+) and N (-). It is guaranteed that M + N = Number of question mark(?).
1 <= Length of String <= 10000
Example : String : ((1?(5?7))?((6?2)?7)) M = 3, N = 2
if we put 3 plus (+) and 2 minus (-) then, ((1-(5-7))+((6+2)+7)) Answer : 18
How to tackle this Problem?