Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 924 Bytes

File metadata and controls

22 lines (16 loc) · 924 Bytes

Most Frequently Occurring Item in an Array

Problem Description

Find the most frequently occurring item in an array. Example: The most frequently occurring item in [1, 3, 1, 3, 2, 1] is 1. If you're given an empty array, you should return null (in Java) or None (in Python). You can assume that there is always a single, unique value that appears most frequently unless the array is empty. For instance, you won't be given an array such as [1, 1, 2, 2]. NOTE: Use lists instead of arrays in Python for simplicity.

Solution

I've written an implementation that determines the solution in linear time complexity (O(n)).

Languages Implemented: