add new solutions
This commit is contained in:
parent
51975f3386
commit
489fa73880
13 changed files with 437 additions and 3 deletions
17
solutions/20/q2073/solution.go
Normal file
17
solutions/20/q2073/solution.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package q2073
|
||||
|
||||
func timeRequiredToBuy(tickets []int, k int) int {
|
||||
wants := tickets[k]
|
||||
|
||||
totalTime := 0
|
||||
for i := range tickets {
|
||||
if i <= k {
|
||||
totalTime += min(wants, tickets[i])
|
||||
} else {
|
||||
totalTime += min(wants-1, tickets[i])
|
||||
}
|
||||
}
|
||||
return totalTime
|
||||
}
|
||||
|
||||
var _ = timeRequiredToBuy
|
||||
Loading…
Add table
Add a link
Reference in a new issue