Relative Sorting — Asked in Google, Microsoft and Visa Interview

Problem Statement :

ARR = { 9, 5, 8, 4, 6, 5 } and BRR = { 8, 4, 5 }
{ 8, 4, 5, 5, 6, 9 }

Approach :

Code :

Thanks for Reading

Upskilling students for tech placements!