- Equalise the array Hackerrank Solution

import math

import os
import random
import re
import sys

#
# Complete the 'equalizeArray' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER_ARRAY arr as parameter.
#

def equalizeArray(arr):
    # Write your code here
    length=len(arr)
    
    list1=[arr.count(item) for item in arr]
    max_occuar=max(list1)
    return (length-max_occuar)
            

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    n = int(input().strip())

    arr = list(map(intinput().rstrip().split()))

    result = equalizeArray(arr)

    fptr.write(str(result) + '\n')

    fptr.close()


Post a Comment

Previous Post Next Post