Python 5 lines


  • 0
    J
        def findMinMoves(self, ms):
            if sum(ms) % len(ms) != 0: return -1
            avg = sum(ms)/len(ms)
            ds = map(lambda x: x-avg, ms)
            dss = [abs(sum(ds[0:i])) for i in xrange(len(ds))]
            return max(dss + ds)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.