You are viewing a single comment's thread. Return to all comments →
c# code, O(nlogn)
public static string organizingContainers(List<List<int>> container) { int n = container.Count; List<long> containerCapacity = new List<long>(); List<long> ballByTypeCount = new List<long>(); for (int i = 0; i < n; i++) { containerCapacity.Add(0); ballByTypeCount.Add(0); } for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ containerCapacity[i] += container[i][j]; ballByTypeCount[j] += container[i][j]; } } containerCapacity.Sort(); ballByTypeCount.Sort(); for (int i = 0; i < n; i++){ if (containerCapacity[i] != ballByTypeCount[i]) return "Impossible"; } return "Possible"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Organizing Containers of Balls
You are viewing a single comment's thread. Return to all comments →
c# code, O(nlogn)