Re: [閒聊] 每日leetcode

作者: oinishere (是oin捏)   2024-04-08 11:32:21
※ 引述 《sustainer123 (caster)》 之銘言:
:  
: https://leetcode.com/problems/number-of-students-unable-to-eat-lunch
:  
: 1700. Number of Students Unable to Eat Lunch
:  
: 齁樓提供PM跟MC兩種貼貼 分別用0跟1表示
:  
: 全部齁粉站在一queue 每個齁粉喜歡PM或MC
:  
: 貼貼數量與齁粉數量相等 貼貼被放在一stack
:  
: 如果queue前面的齁粉喜歡stack頂端的貼貼 他會拿走貼貼
: 否則他會放下貼貼並回到queue最後面
:  
: 循環反覆 直至剩下的齁粉都不想拿stack最頂端的貼貼 他們就會去公園
:  
: 請回傳公園民的數量
:  
解法思路 :
照著題目要求的做
欸欸我leetcode point 2400了欸
這個要換什麼比較好
有人有換過東西嗎
好像可以炫耀欸
class Solution {
public:
int countStudents(vector<int>& students, vector<int>& sandwiches)
{
int wp = 0;
int sp = 0;
int one = 0;
int zero = 0;
int len = students.size();
int lens = sandwiches.size();
for(int k : students)
{
if(k)one ++;
else zero ++;
}
int ok = 1;
int hungry = len ;
while(wp < lens)
{
if(sandwiches[wp] == 1)
{
if(one == 0)return hungry;
while(students[sp%len] != 1)
{
sp ++;
}
students.erase( students.begin()+sp%len );
len
作者: JIWP (JIWP)   2023-04-08 11:32:00
大師
作者: oinishere (是oin捏)   2024-04-08 11:33:00
噓三小 我等等就去把你噓噓的地方剪掉
作者: JIWP (JIWP)   2024-04-08 11:35:00
噓你怎麼了
作者: amsmsk (449)   2024-04-08 11:36:00
你自己剪掉就好 你只需要大號的地方
作者: JIWP (JIWP)   2024-04-08 11:37:00
快滾回花蓮
作者: oinishere (是oin捏)   2024-04-08 11:41:00
哭了 你們怎麼這麼凶 你們的性癖就是對喜歡的人噓噓吧
作者: Rushia (みけねこ的鼻屎)   2024-04-08 11:59:00
存7800

Links booklink

Contact Us: admin [ a t ] ucptt.com