Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use dynamic programming.
The state would be the index in arr1 and the index of the previous element in arr2 after sorting it and removing duplicates.
Solve with full IDE support and test cases