Time complexity of this algorithm?

time complexity of this algorithm is O(n**2)??

@Vipin_coder
the question u have tagged can be solved with different algorithms. I’m not sure which algorithm you are referring to

here is o(n) solution if u want to know


and nlogn" :

can you share java code please?

Sure
this is nlogn approach

Thank you so much, sort by value of HashMap in java is hard as compared to cpp :zipper_mouth_face:

no problem :slight_smile: just try to understand it once by dry running the code and it ll get easier .

If this resolves your doubt please mark it resolved