C# Code

  • 0
    public class Solution {
        public string OptimalDivision(int[] nums) {
            if (nums.Length==1) return nums[0].ToString();
            string str=String.Join("/",nums);
            if (nums.Length==2) return str;
            int x=str.IndexOf("/");
            return str.Substring(0,x+1)+"("+str.Substring(x+1,str.Length-x-1)+")";

    C# code -> Idea is to minimize denominator.
    How to do this =>
    Can be achieved by

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.