![]() |
Given string str that contains only digits, the task is to return an expression by inserting the ‘+’ or ‘*’ operator between every two digits such that the arithmetic value of the expression is minimized. Example:
Approach: The given problem can be solved using a greedy approach. Follow the steps below to solve the problem:
Below is the implementation of the above approach: C++
Java
Python3
C#
Javascript
Output
3+9*1*1*1+8+5+7*1
Time Complexity: O(N)
|
Reffered: https://www.geeksforgeeks.org
Mathematical |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |