Skip to content

Commit 6ce7911

Browse files
authored
Update Binary Search - Leetcode 704.py
1 parent 1e97bea commit 6ce7911

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Binary Search - Leetcode 704/Binary Search - Leetcode 704.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# Brute Force Solution
2+
class Solution:
3+
def search(self, nums: List[int], target: int) -> int:
4+
n = len(nums)
5+
for i in range(n):
6+
if nums[i] == target:
7+
return i
8+
return -1
9+
# Time: O(n)
10+
# Space: O(1)
11+
112
class Solution:
213
def search(self, nums: List[int], target: int) -> int:
314
left = 0

0 commit comments

Comments
 (0)