Skip to content

Commit d263dc7

Browse files
Merge pull request #41 from PsTerminator7/patch-1
Done!
2 parents 73d81b0 + 039e16d commit d263dc7

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎findNLargest.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Python program to find N largest
2+
# element from given list of integers
3+
4+
# Function returns N largest elements
5+
def Nmaxelements(list1, N):
6+
final_list = []
7+
8+
for i in range(0, N):
9+
max1 = 0
10+
11+
for j in range(len(list1)):
12+
if list1[j] > max1:
13+
max1 = list1[j];
14+
15+
list1.remove(max1);
16+
final_list.append(max1)
17+
18+
print(final_list)
19+
20+
# Driver code
21+
list1 = [2, 6, 41, 85, 0, 3, 7, 6, 10]
22+
N = 2
23+
24+
# Calling the function
25+
Nmaxelements(list1, N)

0 commit comments

Comments
 (0)