Easy python sol using dict()


#1

def solve(self, a):

    d=dict();n=len(a)
    for i in range(n):
        if a[i] in d.keys():
            d[a[i]].sort()
            d[a[i]].append(i)
            k=d[a[i]][0]
            d[a[i]].pop(0)
            a[k]+=1;
            if a[k] in d: d[a[k]].append(k)
            else: d[a[k]]=[k]
        else: d[a[i]]=[i]
    return a