?LeetCode刷題實(shí)戰(zhàn)252:會(huì)議室
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.
示例
示例 1:
輸入: [[0,30],[5,10],[15,20]]
輸出: false
示例 2:
輸入: [[7,10],[2,4]]
輸出: true
解題
class Solution { //C++
public:
bool canAttendMeetings(vector<vector<int>>& intervals) {
sort(intervals.begin(), intervals.end(),[&](auto a, auto b){
return a[0] < b[0];
});
for(int i = 1; i < intervals.size(); ++i)
{
if(intervals[i-1][1] > intervals[i][0])
return false;
}
return true;
}
};
LeetCode1-240題匯總,希望對(duì)你有點(diǎn)幫助!
LeetCode刷題實(shí)戰(zhàn)241:為運(yùn)算表達(dá)式設(shè)計(jì)優(yōu)先級(jí)
LeetCode刷題實(shí)戰(zhàn)242:有效的字母異位詞
LeetCode刷題實(shí)戰(zhàn)243:最短單詞距離
LeetCode刷題實(shí)戰(zhàn)244:最短單詞距離 II
LeetCode刷題實(shí)戰(zhàn)245:最短單詞距離 III
LeetCode刷題實(shí)戰(zhàn)246:中心對(duì)稱(chēng)數(shù)
LeetCode刷題實(shí)戰(zhàn)247:中心對(duì)稱(chēng)數(shù)II
LeetCode刷題實(shí)戰(zhàn)248:中心對(duì)稱(chēng)數(shù)III
LeetCode刷題實(shí)戰(zhàn)249:移位字符串分組
LeetCode刷題實(shí)戰(zhàn)250:統(tǒng)計(jì)同值子樹(shù)
LeetCode刷題實(shí)戰(zhàn)251:展開(kāi)二維向量
