252. Meeting Rooms ¶ Time: $O(\texttt{sort})$ Space: $O(\texttt{sort})$ C++JavaPython 1 2 3 4 5 6 7 8 9 10 11 12class Solution { public: bool canAttendMeetings(vector<vector<int>>& intervals) { ranges::sort(intervals); for (int i = 1; i < intervals.size(); ++i) if (intervals[i - 1][1] > intervals[i][0]) return false; return true; } }; 1 2 3 4 5 6 7 8 9 10 11class Solution { public boolean canAttendMeetings(int[][] intervals) { Arrays.sort(intervals, (a, b) -> Integer.compare(a[0], b[0])); for (int i = 1; i < intervals.length; ++i) if (intervals[i - 1][1] > intervals[i][0]) return false; return true; } } 1 2 3 4 5 6 7 8 9class Solution: def canAttendMeetings(self, intervals: list[list[int]]) -> bool: intervals.sort() for i in range(1, len(intervals)): if intervals[i - 1][1] > intervals[i][0]: return False return True