You are viewing a single comment's thread. Return to all comments →
C#
public static List<int> cutTheSticks(List<int> arr) { List<int> stickCut = new List<int>(); stickCut.Add(arr.Count); arr.Sort(); while (arr.Count > 0) { int min = arr[0]; for (int i = 0; i < arr.Count; i++) { arr[i] = arr[i] - min; } arr.RemoveAll(x => x == 0); stickCut.Add(arr.Count); } stickCut.RemoveAt(stickCut.Count - 1); return stickCut; }
Seems like cookies are disabled on this browser, please enable them to open this website
Cut the sticks
You are viewing a single comment's thread. Return to all comments →
C#