leetcode553

public class Solution {
    public string OptimalDivision(int[] nums) {
        if (nums.Length == 0)
            {
                return "";
            }
            else if (nums.Length == 1)
            {
                return nums[0].ToString();
            }
            else if (nums.Length == 2)
            {
                return nums[0] + "/" + nums[1];
            }
            else
            {
                var first = nums[0];
                var dv = nums[1];
                StringBuilder sb = new StringBuilder(first + "/(");
                for (int i = 1; i < nums.Length; i++)
                {
                    sb.Append(nums[i]);
                    sb.Append("/");
                }
                sb.Remove(sb.Length - 1, 1);
                sb.Append(")");

                return sb.ToString();
            }
    }
}

https://leetcode.com/problems/optimal-division/#/description

原文地址:https://www.cnblogs.com/asenyang/p/6797384.html