Problem Link.
I am facing Time Limit Exceed in this problem and I am not able to improve my code any further.
(The following code is in python, but I have even tried in same thing in C++ and got TLE for last test case.)
I have implemented the method from this Link of CP-Algorithms in my code.
Please read my code. I have mentioned what could be the bottleneck in my code, and I don't know how to overcome this problem. If I avoid removing edges from graph, then how should I track what edges not to visit.
Thanks in advance and If you want to help and don't understand what my problem is or anything else just comment for the same I would try to explain better what is my issue here.
Also you can simply comment some links or similar problems related to this so that I can do some further research.
Any kind of help is acceptable :)
Change graph to set and it will probably pass. I have solved it using set.
Thanks a lot buddy, I don't know why it didn't strike me to use sets. Anyways I am attaching my accepted code for those people who may stumble here in future for the same problem.
I recommend to try with sets if not considered, before looking at code.
Can u not use dfs to find euler path in an undirected graph? If so, can u pls share the code with me?
Search "thcy github cses solution"
Hi, You can find pseudo code here:: https://cp-algorithms.com/graph/euler_path.html#algorithm
Pasting a simple CPP implementation for any future reader. Using sets really eased the implementation.
Can you tell why this is not working