This problem can be solved by below given ways:1. Using Map2. Using merge Sort or Divide and Conquer3. Using Recursive4. Using Priority Queue