-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution2848.go
More file actions
33 lines (29 loc) · 801 Bytes
/
Copy pathsolution2848.go
File metadata and controls
33 lines (29 loc) · 801 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
package solution2848
// ============================================================================
// 2848. Points That Intersect With Cars
// URL: https://leetcode.com/problems/points-that-intersect-with-cars/
// ============================================================================
/*
$ go test -bench=. -benchmem
goos: linux
goarch: amd64
pkg: GoLeetCode/solutions/2848---Points-That-Intersect-With-Cars
cpu: 13th Gen Intel(R) Core(TM) i7-13700K
Benchmark_numberOfPoints-24 100000000 14.07 ns/op 0 B/op 0 allocs/op
PASS
*/
func numberOfPoints(nums [][]int) int {
ans := 0
freq := [101]int{}
for _, pair := range nums {
a := pair[0]
b := pair[1]
for j := a; j <= b; j++ {
if freq[j] == 0 {
ans++
}
freq[j] = 1
}
}
return ans
}