We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def countSwaps(a):
i=0
swap=0
for j in a:
for i in range(len(a)-1):
if a[i]
print("First Element:",a[0])
print("Last Element:",a[n-1])
n = int(input("no. of inputs:"))
a = list(map(int, input("enter the list to be sorted:").strip().split()))
countSwaps(a)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sorting: Bubble Sort
You are viewing a single comment's thread. Return to all comments →
def countSwaps(a): i=0 swap=0 for j in a:
for i in range(len(a)-1): if a[i] print("First Element:",a[0]) print("Last Element:",a[n-1]) n = int(input("no. of inputs:")) a = list(map(int, input("enter the list to be sorted:").strip().split())) countSwaps(a)