|
@@ -4,7 +4,7 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
)
|
|
)
|
|
|
|
|
|
-/* func search(nums []int, target int) bool {
|
|
|
|
|
|
+func search(nums []int, target int) bool {
|
|
beg, end := 0, len(nums)-1
|
|
beg, end := 0, len(nums)-1
|
|
// for empty array
|
|
// for empty array
|
|
if end == -1 {
|
|
if end == -1 {
|
|
@@ -38,7 +38,7 @@ import (
|
|
return binarySearch(nums, target, 0, beg)
|
|
return binarySearch(nums, target, 0, beg)
|
|
}
|
|
}
|
|
return binarySearch(nums, target, beg+1, len(nums)-1)
|
|
return binarySearch(nums, target, beg+1, len(nums)-1)
|
|
-} */
|
|
|
|
|
|
+}
|
|
|
|
|
|
func binarySearch(nums []int, target, beg, end int) bool {
|
|
func binarySearch(nums []int, target, beg, end int) bool {
|
|
for beg <= end {
|
|
for beg <= end {
|