Skip to content

Commit 44d2b79

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

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Given a List of N number a1,a2,a3........an, You have to find smallest number from the List that is repeated in the
2+
# List exactly K number of times.
3+
#
4+
# Input Format
5+
#
6+
# First Line of Input Contain Single Value N, Size of List
7+
# Second Line of Input Contain N Space Separated Integers
8+
# Third Line of Input Contain Single Value K
9+
#
10+
# Output Format
11+
#
12+
# Smallest Integer Value That is Repeated Exactly K Number of Time
13+
#
14+
# Constraints
15+
#
16+
# 0 < N < 100001
17+
# 0 < K < 100001
18+
# 0 < ai < 100001
19+
#
20+
# NOTE
21+
# There Will Be Atleast One Variable Which Is Repeated K Times
22+
#
23+
# SAMPLE INPUT
24+
# 5
25+
# 2 2 1 3 1
26+
# 2
27+
#
28+
# SAMPLE OUTPUT
29+
# 1
30+
31+
n = int(input())
32+
array = [int(i) for i in input().split()]
33+
arrayCheck = list(set(array))
34+
k = int(input())
35+
nos = []
36+
count = 0
37+
for i in range(len(arrayCheck)):
38+
count = array.count(arrayCheck[i])
39+
if count == k:
40+
nos.append(arrayCheck[i])
41+
42+
nos.sort()
43+
print(nos[0])

0 commit comments

Comments
 (0)