REL101 - Editorial

PROBLEM LINK:

Practice 

Contest

Author: Divyesh Savaliya 

Editorialist: Divyesh Savaliya

DIFFICULTY:

Cakewalk

PREREQUISITES:

Hashing

PROBLEM:

Given an array of N elements. You have to count the minimum number of replacement require to make all the numbers in array similar. The range of every element of array is from 1 to 9 inclusive.

EXPLANATION:

Count the frequency of each element of array. Lets frequencies are contained in the array freq[10]. Find the maximum number in array freq. The answer is (N - maximum frequency).

Time complexity is O(N).

AUTHOR’S SOLUTIONS:

Author’s solution can be found here.