I have brainstormed this problem: “given a slice of daily stock prices, you can buy, sell or keep at most one stock, determine maximum possible profit”.

Initially I confused myself into trying dynamic programming, but the superior solution is linear. I had an “aham” moment when realizing the solution was linear, and realize there is a lesson to be learned here.

My question is about learning strategy: what lesson learned by solving this problem can I write down and thus compose a large cheat sheet that will serve as quick recap material for future coding& whiteboard challenges ?

Did anyone here ever trained on such problems and took notes ? Can you give some details on what you did to formulate and remmeber the lessons learned, and not simply forget them later ?