Skip to content

Instantly share code, notes, and snippets.

@xynophon
Created August 16, 2015 13:04
Show Gist options
  • Select an option

  • Save xynophon/aea781e6306f5c8c43eb to your computer and use it in GitHub Desktop.

Select an option

Save xynophon/aea781e6306f5c8c43eb to your computer and use it in GitHub Desktop.
LeetCode Meeting Rooms
import java.util.*;
public class MeetingRooms {
public class Interval {
int start;
int end;
Interval() {
start = 0;
end = 0;
}
Interval(int s, int e) {
start = s;
end = e;
}
}
public boolean canAttendMeetings(Interval[] intervals) {
Arrays.sort(intervals, new Comparator<Interval>() {
@Override
public int compare(Interval o1, Interval o2) {
return o1.start - o2.start;
}
});
for (int i = 0; i < intervals.length - 1; i++) {
if (intervals[i].end > intervals[i + 1].start) {
return false;
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment