Resume Review Live & Chill stream, next live coming on 500 Subs ❤ - kzbin.infoHqMOVoWas-Q?si=gI-ufL6JtGeE91p2
@codingkart2455 ай бұрын
Brute force, but using a bool value to check if there is repeatation: int countStudents(vector& students, vector& sandwiches) { stack st; for(int i = sandwiches.size()-1;i>=0;i--){ st.push(sandwiches[i]); } queue que; for(int i = 0;i
@greynorld15805 ай бұрын
i had tried it using vector itself and got a runtime of 0 ms int countStudents(vector& students, vector& sandwiches) { int rotations=0; while(rotations
@pavitrasingh78334 ай бұрын
the first approach for second case is giving 2 as output which is wrong .someone please help me . its working correctly for 1st case .
@mreal_Wakusei5 ай бұрын
i have tried to solve with first approach it doesn't give me desired output: class Solution { public: int countStudents(vector& students, vector& sandwiches) { stackst; //sandwiches stack queueque; //students queue for(int student:students){ que.push(student); } for(int i=st.size()-1; i>=0;i--){ st.push(sandwiches[i]); } int unableToEat=0; while(!que.empty() && !st.empty()){ if(st.top()==que.front()){ que.pop(); st.pop(); unableToEat=0; } else{ que.push(que.front()); que.pop(); unableToEat++; if(unableToEat==que.size()) break; } } return que.size(); } };
@_anteikuu_24005 ай бұрын
you need to return stack size in the end not queue size
@learningmaths7865 ай бұрын
Very good Aryan keep it up
@ARYANMITTAL5 ай бұрын
Thanks a lot sir, aapke coments dekh kar maja aa jaata hai, learning maths ji is always there ❤️❤️🙏