Meeting Rooms

interview_workbook/leetcode/intervals /app/src/interview_workbook/leetcode/intervals/meeting_rooms.py
View Source

Algorithm Notes

Summary: Meeting Rooms — notes not yet curated.
Time: Estimate via loops/recurrences; common classes: O(1), O(log n), O(n), O(n log n), O(n^2)
Space: Count auxiliary structures and recursion depth.
Tip: See the Big-O Guide for how to derive bounds and compare trade-offs.

Big-O Guide

Source

"""
Meeting Rooms

TODO: Add problem description
"""

from src.interview_workbook.leetcode._registry import register_problem
from src.interview_workbook.leetcode._types import Category, Difficulty


class Solution:
    def solve(self, *args):
        """
        Meeting Rooms: Check if a person can attend all meetings.
        Args:
            intervals (List[List[int]])
        Returns:
            bool
        """
        (intervals,) = args
        intervals.sort(key=lambda x: x[0])
        for i in range(1, len(intervals)):
            if intervals[i][0] < intervals[i - 1][1]:
                return False
        return True


def demo():
    """TODO: Implement demo function."""
    pass


register_problem(
    id=252,
    slug="meeting_rooms",
    title="Meeting Rooms",
    category=Category.INTERVALS,
    difficulty=Difficulty.EASY,
    tags=["array", "sorting"],
    url="https://leetcode.com/problems/meeting-rooms/",
    notes="",
)