Re: [閒聊] 每日LeetCode

看板Marginalman作者 (廷廷)時間1年前 (2024/02/18 13:52), 1年前編輯推噓3(304)
留言7則, 4人參與, 1年前最新討論串690/719 (看更多)
第一次寫hard 馬的寫了快兩小時 還差點超過time limit 改天再優化好了 寫到快吐血 2402. Meeting Rooms III class Solution { public: static bool cmp1(vector<long long>& a, vector<long long>& b){ if(a[0]==b[0]) return a[2]<b[2]; return a[0]<b[0]; } static bool cmp2(vector<long long>& a, vector<long long>& b){ if(a[1]==b[1]) return a[2]<b[2]; return a[1]>b[1]; } static bool cmp3(vector<int>& a, vector<int>& b){ return a[0]<b[0]; } int mostBooked(int n, vector<vector<int>>& meetings) { vector<vector<long long>> pq (n, vector<long long>(3,0)); sort(meetings.begin(), meetings.end(), cmp3); for(int i=0; i<n; i++){ pq[i][2]=i; } for(const auto& v:meetings){ for(auto& t:pq){ if(t[0]<=v[0]) t[0]=0; } sort(pq.begin(), pq.end(), cmp1); if(pq[0][0]<v[0]){ pq[0][0]=v[1]; pq[0][1]++; } else{ pq[0][1]++; pq[0][0]+=v[1]-v[0]; } sort(pq.begin(), pq.end(), cmp1); } sort(pq.begin(), pq.end(), cmp2); return pq[0][2]; } }; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.230.5.75 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1708235549.A.F29.html

02/18 13:56, 1年前 , 1F
大師
02/18 13:56, 1F

02/18 13:56, 1年前 , 2F
你hard都會寫 怎麼考不過老黃
02/18 13:56, 2F

02/18 13:56, 1年前 , 3F
hard真的狗幹難 我刷了幾題就果斷躲medium
02/18 13:56, 3F
超花時間 肏雞掰

02/18 13:56, 1年前 , 4F
我聽說老黃coding沒有考很難啊
02/18 13:56, 4F
他考我domain knowledge 跟晶片設計timiing相關的 還有乒乓要去哪看ㄚ 巴哈沒有

02/18 13:57, 1年前 , 5F
大師
02/18 13:57, 5F
※ 編輯: wu10200512 (61.230.5.75 臺灣), 02/18/2024 14:03:22

02/18 14:06, 1年前 , 6F
你要去寫hard dp
02/18 14:06, 6F

02/18 14:08, 1年前 , 7F
我普通的都不一定寫得出來了
02/18 14:08, 7F
文章代碼(AID): #1bqPiTyf (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1bqPiTyf (Marginalman)