i am not understanding in which order we have to print elements … please explain with one test case
Please help me to understand this quesyion language
@kailash_01
Input:
1
5 2
5 1 3 5 2
5 comes : print( { 5 } )
1 comes : print( { 1,5 } )
3 comes : print( { 1,3 } ) , all three have same frequency so taking smaller 2.
5 comes : print( { 5,1 } ) , now 5 has max frequency.
2 comes : print( { 5,1 } )
Final output : 5, 1 5, 1 3, 5 1, 5 1.