Relative Sort Array

Easy
Arrays Array Sorting Hash Table

Sort arr1 by order defined in arr2. Elements not in arr2 go at end sorted.

Constraints

1 ≤ len ≤ 1000

Examples

Example 1:
Input: 2 3 1 3 2 4 6 7 9 2 19 2 1 4 3 9 6
Output: 2 2 2 1 4 3 3 9 6 7 19
▲ Console
📱

Install Talent Enrich

Get instant access to jobs and career tools on your device.