Python3 Simple Clear Logical :)


#1
class Solution:
    # @param A : list of integers
    # @return a list of integers
    def solve(self, A):
        
        d=dict()
        
        for i in range(len(A)):
            if A[i] in d:
                A[d[A[i]]]+=1
                if A[d[A[i]]] in d:
                    if d[A[d[A[i]]]]>d[A[i]]:
                        d[A[d[A[i]]]]=d[A[i]]
                else:
                    d[A[d[A[i]]]]=d[A[i]]
            
            d[A[i]]=i
                
        return A