Task: Given n numbers, I store them in a list and find the second highest.
I found a solution by acisikta19 on Github:
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
max1=arr[-1]
arr.sort(reverse=True)
for x in arr:
if x!=max1:
result = x
print(result)
break
I wanted to ask what max1=arr[-1] does? Particularly the -1?
Second, does arr.sort(reverse=True) simply sort the negative numbers? (The array of numbers is in [-100,100].