Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitea79253

Browse files
authored
Merge pull requestneetcode-gh#2081 from josuebrunel/feat/0252-meeting-rooms.go
Create 0252-meeting-rooms.go
2 parents397d338 +04bbafb commitea79253

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎go/0252-meeting-rooms.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Definition of Interval:
3+
* type Interval struct {
4+
* Start, End int
5+
* }
6+
*/
7+
8+
/**
9+
* @param intervals: an array of meeting time intervals
10+
* @return: if a person could attend all meetings
11+
*/
12+
13+
import"sort"
14+
15+
funcCanAttendMeetings(intervals []*Interval)bool {
16+
// Write your code here
17+
sort.Slice(intervals,func(i,jint)bool {
18+
returnintervals[i].Start<intervals[j].Start
19+
})
20+
21+
fori:=1;i<len(intervals);i++ {
22+
ifintervals[i].Start<intervals[i-1].End {
23+
returnfalse
24+
}
25+
}
26+
returntrue
27+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp