Fix BinarySearch.go style by gofmt (#80)

* Fix BinarySearch.go style by gofmt

* Fix longest_common_subsequence.go style by gofmt
This commit is contained in:
sulinehk
2018-07-26 02:01:40 +08:00
committed by Aditya Bhargava
parent fb0d9dccfd
commit e206a13153
2 changed files with 12 additions and 13 deletions

View File

@@ -4,24 +4,22 @@ import "fmt"
func checkBin(list []int, i int) bool { func checkBin(list []int, i int) bool {
low := 0 low := 0
high := len(list) -1 high := len(list) - 1
for low <= high { for low <= high {
mid:= (low+high)/2 mid := (low + high) / 2
if list[mid] == i{ if list[mid] == i {
return true return true
} }
if list[mid] < i{ if list[mid] < i {
low = mid+1 low = mid + 1
}else { } else {
high = mid -1 high = mid - 1
} }
} }
return false return false
} }
func main() { func main() {
fmt.Println(checkBin([]int{1, 2, 3, 4, 5}, 1)) // true fmt.Println(checkBin([]int{1, 2, 3, 4, 5}, 1)) // true
fmt.Println(checkBin([]int{1, 2, 3, 4, 5}, -1)) //false fmt.Println(checkBin([]int{1, 2, 3, 4, 5}, -1)) //false
} }

View File

@@ -1,10 +1,11 @@
package main package main
import "fmt" import "fmt"
func main(){ func main() {
if word_a[i] == word_b[j] { if word_a[i] == word_b[j] {
cell[i][j] = cell[i-1][j-1]+1 cell[i][j] = cell[i-1][j-1] + 1
}else{ } else {
cell[i][j] = max(cell[i-1][j], cell[i][j-1]) cell[i][j] = max(cell[i-1][j], cell[i][j-1])
} }
} }