Sort by

recency

|

1951 Discussions

|

  • + 0 comments
    def equalizeArray(arr):
        # Write your code here
        dict1={}
        list1=[]
        for i in arr:
            dict1[i]=arr.count(i)
        for j in dict1.values():
            list1.append(j)
        list1.remove(max(list1))
        return sum(list1)``
    
  • + 0 comments

    Emergency Locksmith provides fast, reliable, and professional locksmith services for homes, offices, and vehicles. Whether it’s an urgent lockout, key replacement, or security upgrade, skilled technicians are available 24/7 to ensure your property stays secure. Just like the “Equalize the Array” concept balances and organizes elements efficiently, a trusted emergency locksmith restores order and safety to your property. Count on expert service for peace of mind and dependable protection every time.

  • + 0 comments

    def equalizeArray(arr): # Write your code here dic = Counter(arr)

    max_val = max(dic.values())
    
    return (sum(dic.values())-max_val)
    
  • + 0 comments

    **Simple Python Solution **

    from collections import Counter as c 
    
    def equalizeArray(arr):
        dict = c(arr)
        m = max(dict.values())
        return len(arr)-m 
    
  • + 0 comments

    Time Complexity:

    def equalizeArray(arr:list):
        lenght = len(arr)
        frequency = {}
        for num in arr:
            if num not in frequency:
                frequency[num] = 1
            else:
                frequency[num] += 1
        
    
        return abs(max(frequency.values()) - lenght)