Most of the programmers use C++ as their primary language and so they don't know the struggle we java users face during programming. Getting TLE by using Arrays.sort because( It is O(n2) when the array is already sorted and so you have to make your own sorting function), Using fastreader function to make input-output fast otherwise our code will give TLE for sure , Not having multiset( but we can make it ) and many more. But even after all these we enjoy using it because some Websites like Codechef manage their time according to the language for example https://www.codechef.com/viewsolution/55474317, in this problem time limit is 1sec and my java code takes 1.11sec but it got AC because they have considered the slow factor in java. But yesterday I decided to solve Graph problems on a very reputed site CSES(https://cses.fi/problemset/) First 3 graph problems are based on simple dfs and bfs, I am not a very good coder but I m also not that bad to make a mistake in these simple questions , yes in all the first 3 questions i tried I got TLE in some test cases even though the solution was all correct. I don't know why they are not improving this but being stuck at a problem for hours which you did all correct sucks man. These are the links to these problems and my submissions.
Problem 1 — https://cses.fi/problemset/task/1192 My solution of 1- https://cses.fi/paste/a16c146e9b3a6899349ca1/ Problem 2 — https://cses.fi/problemset/task/1193 My solution of 2- https://cses.fi/paste/473f7daa433fae6f2fd15e/ Problem 3 — https://cses.fi/problemset/task/1666 My solution of 3- https://cses.fi/paste/745fd2ee6a11529e349da5/ I am pretty sure my codes are all right, but if I am doing some mistake please tell me.