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.
# pure maths defmedian(arr):arr.sort()iflen(arr)%2==1:ret_value=arr[int((len(arr)-1)/2)]else:ret_value=0.5*(arr[int(len(arr)/2-1)]+arr[int(len(arr)/2)])returnret_value#when yer graduated but cheated deffindMedian(arr,n):returnmedian(sorted(arr))if__name__=='__main__':n=int(input())arr=list(map(int,input().split(' ')))print(findMedian(arr,n))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Median
You are viewing a single comment's thread. Return to all comments →