SHARE
TWEET

Untitled

a guest Jul 19th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution:
  2.     def reconstructQueue(self, p: List[List[int]]) -> List[List[int]]:
  3.         p.sort()
  4.         n = len(p)
  5.         for i in range(n - 1, -1, -1):
  6.             cur = p[i]
  7.             ctn = 0
  8.             for j in range(i - 1, -1, -1):
  9.                 if p[j][0] != cur[0]:
  10.                     break
  11.                 ctn += 1
  12.             it = cur[1] - ctn
  13.             for j in range(it):
  14.                 p[i + j] = p[i + j + 1]
  15.             p[i + it] = cur
  16.         return p
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