Minimum Cost To Make String Valid Ninja has been given a string ‘STR’ containing either ‘{’ or ‘}’. 'STR’ is called valid if all the brackets are balanced. Formally for each opening bracket, there must be a closing bracket right to it. For Example: “{}{}”, “{{}}”, “{{}{}}” are valid strings while “}{}”, “{}}{{}”, “...

read more
CodingNinjas
author
2y

Step 1 : I gave the most optimized approach with O(n) time complexity. 
I shouldn't have done that. You should always start with the brute force approach and then optimize that.

CodingNinjas
author
2y
RecursionThe idea for this approach is to consider every bracket and then recursively count the number of reversals. We will have only two cases: either a bracket remains the same or converted to...
see more
CodingNinjas
author
2y
StackWe can use a stack to solve this problem. This approach aims to first remove valid parts of ‘STR’. For example, if ‘STR’ is “}{{}{” we will remove the valid part “{}” from ‘STR’ and the remaining...
see more
Add answer anonymously...
Adobe Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2023 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter