I came across this problem on hacker earth contest. I was only able to think of a solution in O(n^2) time complexity. Can anyone share their approach with better time complexity.
I came across this problem on hacker earth contest. I was only able to think of a solution in O(n^2) time complexity. Can anyone share their approach with better time complexity.
What can be used in Java in place of ordered_set in C++?
I came across a question where I have to store to pair in PriorityQueue in Java. But Java does not have anything like make_pair in C++. What can be the alternate used in Java for making a pair?