Algorithm: Check if all vertices have even degree
Check if graph is connected (DFS from vertex )
If checks pass, run Hierholzer starting from vertex
Output the resulting path
Implementation detail: For undirected graphs, each edge appears twice in the adjacency list. When you use one direction, mark both as used.
A common approach: store edge indices and mark edges by index rather than by endpoint pairs.
This runs in time and uses space.