Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Dec 15, 2023
1 parent 5dc67e8 commit a09c6d0
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"fmt"
"sort"
)

func findMinArrowShots(points [][]int) int {
result := 0
sort.Slice(points, func(i, j int) bool { return points[i][1] < points[j][1] })
last := -99999999999999
for _, p := range points {
a, b := p[0], p[1]
if a > last {
result++
last = b
}
}

return result
}

func main() {
points := [][]int{{10, 16}, {2, 8}, {1, 6}, {7, 12}}
fmt.Println(findMinArrowShots(points))
}

0 comments on commit a09c6d0

Please sign in to comment.