-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathAnswer81.cpp
More file actions
37 lines (23 loc) · 711 Bytes
/
Answer81.cpp
File metadata and controls
37 lines (23 loc) · 711 Bytes
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
32
33
34
35
36
37
#define st students
#define sa sandwiches
class Solution {
public:
int countStudents(vector<int>& students, vector<int>& sandwiches) {
int i=0,j=0,flag=0,c=0;
while(i<students.size() && j<sandwiches.size()){
if(st[i]==sa[j]){
i++;
j++;
c=0;
}
else{
c++;
st.push_back(st[i]);
i++;
}
if(c==st.size()-i)
break;
}
return c;
}
};