Skip to content

Commit

Permalink
go implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Azureki committed Apr 28, 2019
1 parent 8a4f57f commit ec09832
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package problem744

func nextGreatestLetter(letters []byte, target byte) byte {
if letters[len(letters)-1] <= target {
return letters[0]
}
left, right := 0, len(letters)-1
var mid int
for left < right {
mid = (left + right) / 2
if letters[mid] <= target {
left = mid + 1
} else {
right = mid
}
}
return letters[left]
}

0 comments on commit ec09832

Please sign in to comment.