1.1 Solved using set, dictionary and sorting
1.2 Solved in C by swapping elements around the mid