We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
How is this question different from just iteratively removing the smallest elements? I tried the following, and it passes test cases, but fails most of the others.
List number = new List();
while (arr.Count > 0)
{
number.Add(arr.Count);
arr.RemoveAll(i => i == arr.Min());
}
return number;
Cookie support is required to access HackerRank
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 →
How is this question different from just iteratively removing the smallest elements? I tried the following, and it passes test cases, but fails most of the others.
List number = new List(); while (arr.Count > 0) { number.Add(arr.Count); arr.RemoveAll(i => i == arr.Min()); } return number;