Skip to content
Onsite

Migratory Birds

EasyP3Coding

Each element of sightings is the type id of a bird that was seen. Return the id of the type seen most often. If several types tie for the highest count, return the smallest id among them.

Example 1

Input
sightings = [1,4,4,4,5,3]
Output
4
Why
Type 4 was seen three times.

Example 2

Input
sightings = [1,2,3,4,5,4,3,2,1,3,4]
Output
3
Why
Types 3 and 4 tie at three sightings; the smaller id is 3.

Example 3

Input
sightings = [7]
Output
7

Constraints

  • 1 <= sightings.length <= 2 * 10^5
  • 1 <= sightings[i] <= 10^9

Hints

Run checks the 3 visible tests, Submit all 10.