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 {
low := 0
high := len(list) -1
high := len(list) - 1
for low <= high {
mid:= (low+high)/2
if list[mid] == i{
mid := (low + high) / 2
if list[mid] == i {
return true
}
if list[mid] < i{
low = mid+1
}else {
high = mid -1
if list[mid] < i {
low = mid + 1
} else {
high = mid - 1
}
}
return false
}
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
}

View File

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