LeetCode - 1700. Number of Students Unable to Eat Lunch

henu·2024년 1월 12일
0

LeetCode

목록 보기
161/186

Solution

var countStudents = function(students, sandwiches) {
    while(students.includes(sandwiches[0])) {
        if(students[0] === sandwiches[0]) {
            students.shift()
            sandwiches.shift()
        } else {
            students.push(students.shift())
        }
    }

    return students.length
};

Explanation

0개의 댓글