Leetcode 1 - Twosum

On the first Leetcode question we need to achieve a target number by summing numbers from known list. We can solve this problem in two ways: brute force, which tries all combinations, or by using a dictionary for a more efficient lookup. Brute force - the easiest solution- but where’s the efficiency? I have a confession: most of the time, I prefer brute force code. It’s simpler and has a Soviet-era feel to it....

April 15, 2024 · 2 min