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.
Test Case 1 and 6 pass but times out for the rest.
Can anyone plz comment or help here.
I am kind of lost here doubting the sorting method provided by python...is it really sorting within stipulated time or not
# Enter your code here. Read input from STDIN. Print output to STDOUT#!/bin/pythonimportsysimportbisectdeffindmedian(lst):l=len(lst)ifl%2==0:med=int(round(float((lst[l/2]+lst[l/2-1])/float(2))))else:med=lst[l/2]returnmeddefnotification(med_arr,arr1,arr):notify=0j=0#import ipdb; ipdb.set_trace()foriinarr1:med=findmedian(med_arr)ifi>=med*2:notify+=1med_arr.remove(arr[j])j+=1bisect.insort(med_arr,i)returnnotifynum,d=raw_input().strip().split(' ')num,d=[int(num),int(d)]arr=map(int,raw_input().strip().split(' '))med_arr=sorted(arr[0:d])arr1=arr[d:]result=notification(med_arr,arr1,arr)printresult
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fraudulent Activity Notifications
You are viewing a single comment's thread. Return to all comments →
Test Case 1 and 6 pass but times out for the rest. Can anyone plz comment or help here.
I am kind of lost here doubting the sorting method provided by python...is it really sorting within stipulated time or not