Leetcode 1217 Solution
This article provides solution to leetcode question 1217 (relative-sort-array)
Access this page by simply typing in "lcs 1217" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/relative-sort-array
Solution
class Solution:
def relativeSortArray(self, arr1: List[int], arr2: List[int]) -> List[int]:
m = {v: i for i, v in enumerate(arr2)}
return sorted(arr1, key=lambda v:m.get(v, v + 10000))