You are given an integer array nums. The adjacent integers in nums will perform the float division.


	For example, for nums = [2,3,4], we will evaluate the expression "2/3/4".


However, you can add any number of parenthesis at any position to change the priority of operations. You want to add these parentheses such the value of the expression after the evaluation is maximum.

Return the corresponding expression that has the maximum value in string format.

Note: your expression should not contain redundant parenthesis.

&nbsp;
Example 1:

Input: nums = [1000,100,10,2]
Output: "1000/(100/10/2)"
Explanation:
1000/(100/10/2) = 1000/((100/10)/2) = 200
However, the bold parenthesis in "1000/((100/10)/2)" are redundant, since they don't influence the operation priority. So you should return "1000/(100/10/2)".
Other cases:
1000/(100/10)/2 = 50
1000/(100/(10/2)) = 50
1000/100/10/2 = 0.5
1000/100/(10/2) = 2


Example 2:

Input: nums = [2,3,4]
Output: "2/(3/4)"


Example 3:

Input: nums = [2]
Output: "2"


&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 10
	2 &lt;= nums[i] &lt;= 1000
	There is only one optimal division for the given iput.


class Solution(object):
    def optimalDivision(self, nums):

        A = list(map(str, nums))
        
        
        if len(A) <= 2:
            
            return '/'.join(A)
        
        
        return A[0] + '/(' + '/'.join(A[1:]) + ')'
class Solution {
    public String optimalDivision(int[] nums) {
    
         if(nums.length==1){
            return nums[0] + "";
        }else if(nums.length==2){
            StringBuilder sb=new StringBuilder();
            sb.append(nums[0] + "/" + nums[1]);
            return sb.toString();
        }
        
        StringBuilder sb=new StringBuilder();
         sb.append(nums[0]);
         sb.append("/(");
       for(int i=1;i<nums.length-1;i++){           
            sb.append(nums[i] + "/");
        }
        sb.append(nums[nums.length-1] + ")");
      
        return sb.toString();
    }
}
class Solution {
public:
    string optimalDivision(vector<int>& nums) {
        string s="";
        if(nums.size()==1)
            return to_string(nums[0]);
        if(nums.size()==2)
            return to_string(nums[0])+'/'+to_string(nums[1]);
        for(int i=0;i<nums.size();i++)
        {
            s+=to_string(nums[i])+"/";
            if(i==0)
                s+="(";
        }
        s[s.size()-1]=')';
        return s;
    }
};
var optimalDivision = function(nums) {
	const { length } = nums;
	if (length === 1) return `${nums[0]}`;
	if (length === 2) return nums.join('/');

	return nums.reduce((result, num, index) => {
		if (index === 0) return `${num}/(`;
		if (index === length - 1) return result + `${num})`;
		return result + `${num}/`;
	}, '');
};
Optimal Division