Problem doubt

Can any one please help me to solve this problem using Greedy approach . I am unable to derive a mathematical claim.

Given
pairs[] = {1->3, 2->6, 4->5}
arr[] = {3, 5, 6, 4, 1, 2}

Count the minimum number of swaps to arrange the elements in the arr[ ] such that each pair in pairs[ ] lie adjacent to each other in arr[ ].

Output : 2

Problem link :