add new solutions
This commit is contained in:
parent
67cad91898
commit
eb6ffe8114
24 changed files with 933 additions and 14 deletions
21
solutions/7/q744/solution.go
Normal file
21
solutions/7/q744/solution.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package q744
|
||||
|
||||
func nextGreatestLetter(letters []byte, target byte) byte {
|
||||
l, r := 0, len(letters)
|
||||
for l < r {
|
||||
m := (l + r) / 2
|
||||
|
||||
if letters[m] <= target {
|
||||
l = m + 1
|
||||
} else {
|
||||
r = m
|
||||
}
|
||||
}
|
||||
|
||||
if l == len(letters) {
|
||||
l = 0
|
||||
}
|
||||
return letters[l]
|
||||
}
|
||||
|
||||
var _ = nextGreatestLetter
|
||||
Loading…
Add table
Add a link
Reference in a new issue