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.
defquartiles(arr):# Write your code herearr.sort()defmedian(arr1):median_1st_index=len(arr1)//2#below same as 1st @ even elemsmedian_2nd_index=(len(arr1)//2)-(len(arr1)%2==0)returnint((arr1[median_1st_index]+arr1[median_2nd_index])/2)idxstart3q=((len(arr)%2!=0)+len(arr)//2)returnmedian(arr[:len(arr)//2]), median(arr), median(arr[idxstart3q:])
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 1: Quartiles
You are viewing a single comment's thread. Return to all comments →
python3: