I've been tackling LeetCode challenges for about a month now and initially aimed to avoid built-in functions to better grasp algorithms. However, I found myself spending a lot of time on one problem that could have been solved in just two minutes using built-ins. So, I'm wondering: should I stick to avoiding built-ins to really understand the algorithms behind the problems? For instance, in problem 151, my approach ended up being really messy and hard to read, which is not ideal if I were collaborating with others. What do you all think?
4 Answers
Honestly, don't overthink it too much. Your messy code is what interviewers are often looking for. A clean one-liner with built-ins might actually hurt you more than help. Plus, working through the messy solution helps you learn more!
I think it's fine to use built-in functions and standard data structures as long as they aren't central to the problem. For example, using a hashtable might be acceptable unless the problem specifically revolves around implementing one. In your case, though, using functions like split, reverse, and join might defeat the purpose of the task since it essentially asks you to reverse the words in a string.
Totally get what you're saying! If the task is literally about "reversing words in a string," then relying on split().reverse().join() takes away from the learning experience. On the other hand, using a hashtable for lookups in a totally different problem? That’s just smart coding!
There are two parts to this:
1. Use functions that speed up your coding without sacrificing performance. If the problem doesn’t need a super optimized approach, feel free to use built-ins.
2. Take a step back and consider why your code is looking messy. Can it be simplified? Sometimes there's a more elegant solution.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically