NumPy solution


  • 0
    import numpy as np
    
    class Solution(object):
        def minDistance(self, height, width, tree, squirrel, nuts):
            nuts2tree = abs(np.array(nuts) - tree).sum(1)
            nuts2sqrl = abs(np.array(nuts) - squirrel).sum(1)
            return int(2 * sum(nuts2tree) - max(nuts2tree - nuts2sqrl))
    

Log in to reply
 

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