You are viewing a single comment's thread. Return to all comments →
c#
static int RealEstateBroker(int[][] clients, int[][] houses) { houses = houses.OrderBy(e => e[0]).ThenBy(e => e[1]).ToArray(); var getters = Enumerable.Range(0, clients.Length).Select(_ => false).ToArray(); int res = 0; houses.ToList().ForEach(house => { var fitters = clients.Select((_, i) => (client: clients[i][1], idx: i)) .Where((v, j) => !getters[j] && clients[j][0] < house[0] && v.client >= house[1]).ToArray(); if (fitters.Any()) { getters[fitters.OrderBy(e => e.client).ThenBy(e => e.idx).ElementAt(0).idx] = true; res++; } }); return res; }
Seems like cookies are disabled on this browser, please enable them to open this website
Real Estate Broker
You are viewing a single comment's thread. Return to all comments →
c#