A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.hackerrank.com/challenges/equality-in-a-array/problem below:

Equalize the Array | HackerRank

Given an array of integers, determine the minimum number of elements to delete to leave only elements of equal value.

Example

Delete the elements and leaving . If both twos plus either the or the are deleted, it takes deletions to leave either or . The minimum number of deletions is .

Function Description

Complete the equalizeArray function in the editor below.

equalizeArray has the following parameter(s):

Returns

Input Format

The first line contains an integer , the number of elements in .
The next line contains space-separated integers .

Sample Input

STDIN       Function
-----       --------
5           arr[] size n = 5
3 3 2 1 3   arr = [3, 3, 2, 1, 3]

Explanation

Delete and to leave . This is minimal. The only other options are to delete elements to get an array of either or .


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4