Skip to content

Commit dc11dbf

Browse files
committed
Algorithms: Linear Search
1 parent 44d2b79 commit dc11dbf

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Given a List of Distinct N number a1,a2,a3........an.
2+
# Find The Position Of Number K In The Given List.
3+
#
4+
# Input Format
5+
#
6+
# First Line Take Input Value Of N
7+
#
8+
# Second Line Take Input N Space Separated Integer Value
9+
#
10+
# Third Line Take Input Value Of K
11+
#
12+
# Output Format
13+
#
14+
# Position Of K In The Given List
15+
#
16+
# Constraints
17+
#
18+
# 0 < N < 100001
19+
# 0 < ai < 100001
20+
# 0 < K < 100001
21+
#
22+
# NOTE:
23+
# Array Indexing Starts From 0
24+
#
25+
# SAMPLE INPUT
26+
# 5
27+
# 1 2 3 4 5
28+
# 4
29+
#
30+
# SAMPLE OUTPUT
31+
# 3
32+
33+
n = int(input())
34+
array = [int(i) for i in input().split()]
35+
k = int(input())
36+
37+
for i in range(len(array)):
38+
if array[i] == k:
39+
print(i)
40+
break

0 commit comments

Comments
 (0)