Relative Content

Tag Archive for javaloopsbacktracking

Using iteration and loops instead of recursion to solve a backtracking leetcode problem?

This is my approach to the problem. I didn’t use recursion or backtracking like we are supposed to but did it iteratively and got a time limit exceeded error. I think my solution is correct despite being very convoluted and lengthy. Could someone help me refine it and slightly correct any mistakes I may be overlooking? I’m not looking for an entirely different solution using recursion but only tweaks to my current one so that it passes all testcases.