Arithmetic Operators

 Given an arithmetic expression containing '+', '-', '*' operators, generate a string by placing parenthesis in the given expression which will return the the maximum possible value of that expression.    

 eg: I/p -------> 8+4*2 O/p ------> ((8+4)*2) corresponding to a max value of 24 

I/p -------> 5-8+7*4-8*9 O/p ------> (5 - ((8 + 7)*(4 - (8*9)))) corresponding to a max value of 1025.

 

CodingNinjas
author
2y

I solved this question using recursion by putting bracket at all possible places and evaluate the answer through recursion and found the maximum out of them.

CodingNinjas
author
2y

We can solve this question by applying paranthesis at all places and then evaluating them using recursion and calculate the maximum answer.It is similiar to matrix chain multiplication concept but we ...read more

Help your peers!
Add answer anonymously...
Cisco Networking Academy Software Developer 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 © 2024 Info Edge (India) Ltd.

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