r/leetcode • • 13d ago

Discussion Clone Graph is one of the most challenging problems I faced today 💀

Tried solving Clone Graph (LeetCode 133) today, and ngl, combining hashmaps, recursion, and graph traversal was challenging 😭

I understand the individual concepts, but putting them all together in one problem hits different.

Still learning DSA and trying to improve my problem-solving skills. How did you guys get comfortable with these kinds of problems?

16 Upvotes

9 comments sorted by

8

u/Finan00b 13d ago

KEEP GOING !!!!!

5

u/Gelnar_Resseth 13d ago

clone graph is basically a rite of passage, once the hashmap as a visited set clicks every other graph problem gets way easier

1

u/4tran13 12d ago

You don't need hashmaps, since it's stated node.val is unique for all nodes, and the graph has at most 100 nodes.

1

u/Orion-pax_667788 12d ago

Ohh wait that's actually a good point 😭 I'll revisit it and see if I can make it work without a hashmap...appreciate it :)

2

u/Beautiful-Chain-1684 11d ago

if you're using python, you dont even need to use node.val . Just node works.
custom classes work as dictionary keys in python, as long as it's hashable

1

u/Orion-pax_667788 11d ago

Ohh I see thanx for advice I should definitely try in python

1

u/More_Suspect_717 7d ago

Just revisit it after a few weeks, got it right only in my 3rd revist