일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 조지아텍
- 방통대
- omscs
- 컴퓨터과학과
- 머신러닝
- LV1
- Deep learning
- 매트랩
- 위니펙
- C++
- 프로그래머스
- mpnp
- 기본
- 온라인석사
- leetcode
- 캐나다 영주권
- zeros
- Plotting
- 딥러닝
- machine learning
- MATLAB
- 방송통신대학교
- 알고리즘
- 개발자
- EOI
- cpp
- LAA
- 선형대수
- 주정부이민
- 코딩테스트
Archives
- Today
- Total
Byte by Byte
1700. Number of Students Unable to Eat Lunch.cpp 본문
🔑 루프 기본 연습
class Solution {
public:
int countStudents(vector<int>& students, vector<int>& sandwiches) {
int cnt = 0;
while(1){
if(sandwiches[0] ==students[0]){
sandwiches.erase(sandwiches.begin());
students.erase(students.begin());
cnt = 0;
}
else{
students.push_back(students[0]);
students.erase(students.begin());
cnt++;
}
if(cnt == students.size()) break;
}
return students.size();
}
};
'개발 로그 > 알고리즘' 카테고리의 다른 글
202. Happy Number.cpp (0) | 2021.11.24 |
---|---|
766. Toeplitz Matrix.cpp (0) | 2021.11.22 |
349. Intersection of Two Arrays.cpp (0) | 2021.11.20 |
1636. Sort Array by Increasing Frequency.cpp (0) | 2021.11.20 |
1002. Find Common Characters.cpp (0) | 2021.11.19 |