Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Min Frequency in Array

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Min Frequency in Array. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

While validating event samples from Nutanix Prism Central, identify the value that appears least often in an array. Return the first value encountered when multiple values share the minimum frequency.

Formal Specification

Implement find_least_frequent(nums), where nums is a non-empty list of integers. Return the integer with the smallest frequency in nums. If several integers have the same minimum frequency, return the one whose first occurrence has the smallest index.

The input array must not be modified.

Constraints

  • 1 <= len(nums) <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • The input contains at least one element
  • Return the first value when minimum frequencies are tied

Function Signature

def find_least_frequent(nums):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output