Skip to content

Commit cb28ab6

Browse files
committed
improve -Implement the linear search algorithm.
1 parent 692935c commit cb28ab6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.pyc
2+
*.swp
23
.idea/

linear_search.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def linear_search(array: list[int], target: int) -> str:
2+
for i in range(len(array)):
3+
if array[i] == target:
4+
return "The {} is in the {} index of the array".format(target, i)
5+
6+
return "Your target is not in the array..."
7+

0 commit comments

Comments
 (0)