Skip to main content
Ask a Question
Python
Asked a question 9 months ago

# to find the second last element # in hackerrank 1> code was accepted but not the 2>code ....what is the difference? 1> n = int(input()) arr = list(map(int, input().split())) largest = max(arr) for i in range(n): if largest == max(arr): # arr.remove(max(arr)) print(max(arr)) # i don't understand why we use (for loop) in 1st code rather than (for loop) we can use below code..... 2> n = int(input()) arr = list(map(int, input().split())) arr.remove(max(arr)) print(max(arr))

Fuel your ambition, discover your passion and achieve your professional goals with LetsUpgrade.
Sign Up Now