• + 0 comments

    C# solution is shown below

    public static List<int> cutTheSticks(List<int> arr) {
            List<int> ret = new List<int>();
            while (arr.Count>0) {
                ret.Add(arr.Count);
                int min = arr.Min();
                List<int> tmp = new List<int>();
                for (int i = 0; i < arr.Count; i++) 
                    if (arr[i] > min) tmp.Add(arr[i] - min); 
                arr = tmp;
            }
            return ret;  
        }