Link to my solution.
Thanks in advance
Heyy I can give the code in C++…If u r able to undestand bcoz i didn’t code in java
Use Fast IO.
I got the same error. It’s because “Scanner” class is rather slow to take input so use Fast IO (Buffered reader). Check this link out Fast I/O in Java in Competitive Programming - GeeksforGeeks
Heyy ,it is showing TLE bcoz scanner class has slow input/output and for the large input it was showing tle to you. You can read some gfg article for fast input/output in java
Or you can check out my solution
Thanks a lot!
Thanks a bunch
Got it! Thanks