You are viewing a single comment's thread. Return to all comments →
what is wrong with this code ?
long gridlandMetro(int n, int m, int k, vector<vector<int>>& track) { long long count = 0; sort(track.begin(), track.end(), [](const vector<int>& a, const vector<int>& b) { return a[0] < b[0]; }); for (int i = 0; i < k; ++i) { int row = track[i][0]; int start_col = track[i][1]; int end_col = track[i][2]; while (i + 1 < k && track[i + 1][0] == row && track[i + 1][1] <= end_col) { end_col = max(end_col, track[i + 1][2]); ++i; } count += end_col - start_col + 1; } long long total_cells = static_cast<long long>(n) * m; return total_cells - count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Gridland Metro
You are viewing a single comment's thread. Return to all comments →
what is wrong with this code ?