{"id":"96e98c31-bbd9-407d-9943-53226ad0cc5e","name":"Min Max Value Expression","description":"1. You are given a string that represents an expression containing numbers and two operators + and *.\r\n2. You have to find the minimum and maximum value which can be obtained by evaluating this expression by different parenthesization.","inputFormat":"A string","outputFormat":"Check the sample output and question video.","constraints":"1 &lt;= length of string &lt;= 100\r\nRange of numbers -&gt; [0,9]","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int[] solution(String str1, String str2) {\r\n\t\t//write your code here\r\n\r\n\t\treturn null;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s = scn.next();\r\n\t\tString str1 = \"\";\r\n\t\tString str2 = \"\";\r\n\t\tfor (int i = 0; i < s.length(); i++) {\r\n\t\t\tchar ch = s.charAt(i);\r\n\t\t\tif (ch == ''+'' || ch == ''*'') {\r\n\t\t\t\tstr2 += ch;\r\n\t\t\t} else {\r\n\t\t\t\tstr1 += ch;\r\n\t\t\t}\r\n\t\t}\r\n\t\tint[] arr = solution(str1, str2);\r\n\t\tSystem.out.println(\"Minimum Value -> \" + arr[0]);\r\n\t\tSystem.out.println(\"Maximum Value -> \" + arr[1]);\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"1+2*3+4*5","sampleOutput":"Minimum Value -> 27\r\nMaximum Value -> 105\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"8f1010b0-00ab-4a0d-9ecf-e10eba378292","name":"Min Max Value Expression","slug":"min-max-value-expression","type":1}],"next":{"id":"6d4b494a-ee6a-4d62-a348-14712ed7fe2d","name":"Ugly Number","type":1,"slug":"ugly-number"},"prev":{"id":"752e53e1-a92b-4233-a084-e43f6d0c44c3","name":"Frog Jump MCQ","type":0,"slug":"frog-jump-mcq"}}}

Min Max Value Expression

1. You are given a string that represents an expression containing numbers and two operators + and *. 2. You have to find the minimum and maximum value which can be obtained by evaluating this expression by different parenthesization.

{"id":"96e98c31-bbd9-407d-9943-53226ad0cc5e","name":"Min Max Value Expression","description":"1. You are given a string that represents an expression containing numbers and two operators + and *.\r\n2. You have to find the minimum and maximum value which can be obtained by evaluating this expression by different parenthesization.","inputFormat":"A string","outputFormat":"Check the sample output and question video.","constraints":"1 &lt;= length of string &lt;= 100\r\nRange of numbers -&gt; [0,9]","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int[] solution(String str1, String str2) {\r\n\t\t//write your code here\r\n\r\n\t\treturn null;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s = scn.next();\r\n\t\tString str1 = \"\";\r\n\t\tString str2 = \"\";\r\n\t\tfor (int i = 0; i < s.length(); i++) {\r\n\t\t\tchar ch = s.charAt(i);\r\n\t\t\tif (ch == ''+'' || ch == ''*'') {\r\n\t\t\t\tstr2 += ch;\r\n\t\t\t} else {\r\n\t\t\t\tstr1 += ch;\r\n\t\t\t}\r\n\t\t}\r\n\t\tint[] arr = solution(str1, str2);\r\n\t\tSystem.out.println(\"Minimum Value -> \" + arr[0]);\r\n\t\tSystem.out.println(\"Maximum Value -> \" + arr[1]);\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"1+2*3+4*5","sampleOutput":"Minimum Value -> 27\r\nMaximum Value -> 105\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"8f1010b0-00ab-4a0d-9ecf-e10eba378292","name":"Min Max Value Expression","slug":"min-max-value-expression","type":1}],"next":{"id":"6d4b494a-ee6a-4d62-a348-14712ed7fe2d","name":"Ugly Number","type":1,"slug":"ugly-number"},"prev":{"id":"752e53e1-a92b-4233-a084-e43f6d0c44c3","name":"Frog Jump MCQ","type":0,"slug":"frog-jump-mcq"}}}
plane

Editor


Loading...

Min Max Value Expression

easy

1. You are given a string that represents an expression containing numbers and two operators + and *. 2. You have to find the minimum and maximum value which can be obtained by evaluating this expression by different parenthesization.

Constraints

1 <= length of string <= 100 Range of numbers -> [0,9]

Format

Input

A string

Output

Check the sample output and question video.

Example

Sample Input

1+2*3+4*5

Sample Output

Minimum Value -> 27 Maximum Value -> 105

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode