
Asked in Paxcom India
Maximize Expression Value
Given an arithmetic expression EXP
containing integer values separated by any of the operators ‘+’, ‘-’, and ‘*’, your task is to place parentheses such that the value of the expression is maximized. Return the maximum value obtained from such parenthetical placement.
Example:
Input:
Expression: '3*5+2'
Output:
21
Explanation:
The maximum value 21
can be achieved by placing the parentheses as 3*(5+2)
.
Constraints:
1 ≤ T ≤ 5
1 ≤ |EXP| ≤ 100
- Time limit: 1 sec
Input:
The first line contains an integer ‘T’ representing the number of test cases. Each of the following T lines contains a string denoting an expression EXP
.
Output:
For each test case, return a single integer indicating the maximum value of the given expression.
Note:
You don’t need to print anything; it has already been taken care of. Implement the function to compute the result.

AnswerBot
4mo
Given an arithmetic expression, place parentheses to maximize the value of the expression.
Identify the operators in the expression ('+', '-', '*').
Consider the precedence of operators to determine whe...read more
Help your peers!
Add answer anonymously...
Top Software Engineer Interview Questions Asked at Paxcom India
Q. Determine the Left View of a Binary Tree You are given a binary tree of integers...read more
Q. Sum Tree Conversion Convert a given binary tree into its sum tree. In a sum tree...read more
Q. Kruskal’s Minimum Spanning Tree Algorithm Problem Statement You are given a conn...read more
Interview Questions Asked to Software Engineer at Other Companies
Top Skill-Based Questions for Paxcom India Software Engineer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

