1
// This code is using 2nd Approach.5
string optimalDivision(vector<int> &nums) {9
// check for size if its 1 then we can't use parantheses and10
// if its 2 then also we should not use it.12
if (n == 1) return ans = to_string(nums[0]);13
if (n == 2) return ans = to_string(nums[0]) + "/" + to_string(nums[1]);15
// for size greater than 2 add paranthese after first number17
ans = to_string(nums[0]);19
for (int i = 1; i < n - 1; i++) {20
ans.append(to_string(nums[i]) + "/");22
ans.append(to_string(nums[n - 1]));25
// finally this becomes as a/(b/c/d/....) which is our answer