[Python] Return Missing balancing numbers

Discussão em 'Python' iniciado por Stack, Fevereiro 6, 2025.

  1. Stack

    Stack Membro Participativo

    A balanced array would be an array in which each element appears the same number of times.

    Given an array with n elements: return a dictionary with the key as the element and the value as the count of elements needed to balance the given array

    Examples

    elements = ["a", "b", "abc", "c", "a"]


    Expected output: {"b":1, "abc":1, "c":1}

    Because there are 2 a, we need 1 more of b, abc, c

    Hope that helps

    Continue reading...

Compartilhe esta Página