Hint Solution is not compiling


#1

Can anyone please explain the solution code?


#2

Hey,
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)

e.g.
Input:
3
1 2
1 3
2 3
Output
2 3
1 3
1 2


#3

While implementing interface use:
class pair implements Comparable
instead of class pair implements Comparable.


#4

Refer to this article: https://www.geeksforgeeks.org/sort-an-array-of-pairs-using-java-pair-and-comparator/


#5

class pair implements Comparable “opening sqr brkt” pair"closing sqr brkt"