Can anyone please explain the solution code?
As in problem statement written,
they given ip/out code and sorting using collection class
you need to create one pair class which contains two integer attributes named as first & second.
for initializing these integers you need to create parameterized constructor as you see in main function while adding into ArrayList. next you need to create custom class which implements comparator interface and write sorting logic as per given condition.
(Hint:- object contains 2 integers you have to sort in descending order by considering second int only if second value is same den go for comparison with first)
While implementing interface use:
class pair implements Comparable
instead of class pair implements Comparable.
Refer to this article: https://www.geeksforgeeks.org/sort-an-array-of-pairs-using-java-pair-and-comparator/
class pair implements Comparable “opening sqr brkt” pair"closing sqr brkt"