Leetcode 1217 Solution

This article provides solution to leetcode question 1217 (relative-sort-array)

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))