Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Apr 8, 2024
1 parent 1a884fa commit b2c953f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions leetcode/1700.NumberofStudentsUnabletoEatLunch/sol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// https://leetcode.com/problems/number-of-students-unable-to-eat-lunch

package main

import (
"fmt"
)

func countStudents(students []int, sandwiches []int) int {
cnt := [2]int{}
for _, v := range students {
cnt[v]++
}
for _, v := range sandwiches {
if cnt[v] == 0 {
return cnt[v^1]
}
cnt[v]--
}
return 0
}

func main() {
students := []int{1, 1, 0, 0}
sandwiches := []int{0, 1, 0, 1}

fmt.Println(countStudents(students, sandwiches))
}

0 comments on commit b2c953f

Please sign in to comment.