Skip to content

Commit 762843e

Browse files
committed
Create 0253-meeting-rooms-ii.swift
1 parent bdaf365 commit 762843e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

swift/0253-meeting-rooms-ii.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution {
2+
func minMeetingRooms(_ intervals: [[Int]]) -> Int {
3+
var start = intervals.map({ $0[0] }).sorted()
4+
var end = intervals.map({ $0[1] }).sorted()
5+
var res = 0
6+
var count = 0
7+
var s = 0
8+
var e = 0
9+
10+
while s < intervals.count {
11+
if start[s] < end[e] {
12+
s += 1
13+
count += 1
14+
} else {
15+
e += 1
16+
count -= 1
17+
}
18+
res = max(res, count)
19+
}
20+
21+
return res
22+
}
23+
}

0 commit comments

Comments
 (0)