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
fnmigratory_birds(arr:&[i32])->i32{//Time complexity: O(n)//Space complexity (ignoring input): O(1). You could use a frequency array instead//of a dictionary and use even less spaceletmutbirds_hash=std::collections::HashMap::new();for&birdinarr{matchbirds_hash.get(&bird){Some(value)=>birds_hash.insert(bird,value+1),None=>birds_hash.insert(bird,1),};}structBirdInfo{bird:i32,frequency:i32,}letmutmost_frequent=BirdInfo{bird:6,frequency:0,};for(bird,frequency)inbirds_hash.iter(){iffrequency>&most_frequent.frequency{most_frequent.bird=*bird;most_frequent.frequency=*frequency}if(frequency==&most_frequent.frequency)&(bird<&most_frequent.bird){most_frequent.bird=*bird;}}most_frequent.bird}
Migratory Birds
You are viewing a single comment's thread. Return to all comments →
Rust 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