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.
Day 20: Sorting
Day 20: Sorting
Sort by
recency
|
621 Discussions
|
Please Login in order to post a comment
Python 3 code if name == 'main': n = int(input().strip())
Python Code:
**Python code: **
for i in range(n): for j in range(i+1): if a[i] < a[j]: a[i], a[j] = a[j], a[i] temp += 1 print(f"Array is sorted in {temp} swaps.") print(f"First Element: {a[0]}") print(f"Last Element: {a[-1]}")