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.
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below:
my solutions
defmigratory_birds(arr):#Time complexity: O(n)#Space complexity (ignoring input): O(1). You could use a frequency array instead#of a dictionary and use even less spacebirds_dict={}forbirdinarr:ifbirdinbirds_dict:birds_dict[bird]+=1else:birds_dict[bird]=1most_frequent=[6,0]for(bird,frequency)inbirds_dict.items():iffrequency>most_frequent[1]:most_frequent=[bird,frequency]if(frequency==most_frequent[1])and(bird<most_frequent[0]):most_frequent[0]=birdreturnmost_frequent[0]
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
Python best solution
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions