Gotcha! global variable with recursion
Be careful with argument order and return values
Published in
5 min readOct 31, 2020
I was working on this leetcode question https://leetcode.com/contest/weekly-contest-212/problems/path-with-minimum-effort/ using backtracking and spent some time debugging strange output. This article discusses some pitfalls when using recursion with global variables, how to handle them, and how to change the code…