The goal with LeetCode and DSA in general is to provide an optimal solution to a problem. But I’ve come to realize that instead of spending precious time trying to figure out that optimal solution from scratch, it’s best to first write out the brute-force approach. Most times, it becomes easier and faster to rework that into the optimal solution.