Are you stuck? Document/Explain your code and you'll probably figure it out!

I’ve been stuck on a LeetCode problem for a couple hours. I got 99% there, but my task was failing ~50% of the time. As I typed out a post for the FreeCodeCamp forum, I realized that it would be much easier for the people helping me if I documented by code and what it did.

I started from line one, slowly adding my explanations. As I got to line 66, I realized that I was returning an empty string when I shouldn’t have been. I changed it, and… voila. The code worked.

Just a tip :smiley:


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.