TLE in java solution [finding connected components]

Правка en1, от I_love_penny, 2021-07-20 11:50:54

Hello I wanted to know how can this java code can be improved. Currently it get TLE in few test cases.It would be helpful if someone can find the bottleneck in this solution.

Problem: https://cses.fi/problemset/task/1192
Solution: find the number of connected components.

code link: https://cses.fi/paste/b4d685acb261aaca26c573/

equivalent code in c++ is 10 times faster than java.

I am trying to switch to java for cp.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский I_love_penny 2021-07-20 11:50:54 507 Initial revision (published)