You are given two integer arrays arr1 and arr2.
All elements of arr2 are distinct and are guaranteed to exist in arr1.
Rearrange arr1 so that:
The elements appear in the same sequence as they appear in arr2.
Any values in arr1 that are not found in arr2 must be placed at the end, sorted in non-decreasing order.
Input: arr1 = [7,5,7,3,9,5,1] arr2 = [5,7,1]
Output: [5,5,7,7,1,3,9]
Input: arr1 = [4,11,4,8,6,8,3] arr2 = [8,4]
Output:
Explanation:
[8,8,4,4,3,6,11]
Accepted:
Submission: