SHARE
TWEET

Untitled

yuntai May 19th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution:
  2.     def gardenNoAdj(self, N: int, paths: List[List[int]]) -> List[int]:
  3.         ret = [1]*N
  4.         dc = collections.defaultdict(list)
  5.         for p in paths:
  6.             dc[max(p)].append(min(p))
  7.            
  8.         for k in sorted(dc):
  9.             ret[k-1] = ({1,2,3,4} - {ret[vv-1] for vv in dc[k]}).pop()
  10.         return ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top