▲ 7 r/LeetcodeChallenge+2 crossposts

Struggling with Trees

Ive realized my biggest issue with trees isn't understanding the concepts it's translating them into code I know what DfS does and I usually understand whether the information should flow upward or downward, but when I start coding, I freeze.

The base case is usually fine. After that I struggle to decide:

  • what recursivee calls to make,
  • what each function should return,
  • when to use && or ||.
  • what conditions belong before recursion and which belong after,
  • whether I should return a value or update a global variable.

I often understand the solution after seeing it, but I have trouble deriving it on my own. It feels like I'm missing the recursive thought process rather than the tree concepts themselves.

reddit.com
u/NoRefrigerator9376 — 9 days ago