# Meeting Rooms

<https://leetcode.com/problems/meeting-rooms/description/>

> Given an array of meeting time intervals consisting of start and end times \[\[s1,e1],\[s2,e2],...] (si < ei), determine if a person could attend all meetings.
>
> For example,
>
> Given \[\[0, 30],\[5, 10],\[15, 20]],
>
> return false.

## Thoughts

interval问题先按start时间排序. 再一个个检查是否有冲突即可.

## Code

```
/**
 * Definition for an interval.
 * public class Interval {
 *     int start;
 *     int end;
 *     Interval() { start = 0; end = 0; }
 *     Interval(int s, int e) { start = s; end = e; }
 * }
 */
class Solution {
    public boolean canAttendMeetings(Interval[] intervals) {
        Arrays.sort(intervals, (a, b) -> a.start - b.start);
        for (int i = 1; i < intervals.length; i++) {
            if (intervals[i].start < intervals[i - 1].end) {
                return false;
            }
        }
        return true;
    }
}
```

## Analysis

时间复杂度O(NlgN).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hao-fu-1.gitbook.io/oj/array_and_numbers/intervals/meeting-rooms.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
