This is related to programming puzzles. I'm a fairly experienced developer and I tend to take to things like CodinGame or HackerRank if I want to familiarize myself with a new language (in addition to other methods, but that's another topic).<p>I often run into the problem of optimization when I get a problem that expects you to realize that you can make assumptions and capitilize on these in code. For example, you might be able to reduce the search space if you know certain items don't need to be checked or that you can create a linear algorithm for an NP problem because of this reduced search space. Often it's something simple like figuring out the behavior of a spiral matrix so you can derive the value at a specific location without iterating through all sequences.<p>So, to go about this, this is my general approach:<p><pre><code> - Look for search speace type optimizations (e.g. if I'm brute forcing do I need to brute force everything or use binary searches or similar techniques to reduce the problem?)
- Plenty of google/wikipedia time trying to understand the algorithms at play (e.g. how to you figure out primes... ok, what's a sieve.. ok...)
- Give up and look for solutions and then try to figure out how they arrived at that solution
</code></pre>
Is there a better approach? Should I skip to other's solutions faster to become more comfortable with this type of work, or am I missing some fundamental process for solving these type of problems? Are there ways to improve on my knowledge that can get me from brute force to optimization faster?