General Problem solving tips
Understand the parameters clearly. There shouldn’t be any muddled thoughts about the problem.
Design the solution iteratively: a. Spec out (through tests or other means) next smallest required behaviour(s). For instance: Edge cases, input parsing etc… b. Once you’re done with one of these, Ensure it passes the spec through tests. c. Repeat until you have the solution
For problems which seem to be extremely complex, try to reduce the problem size in the following ways: a. Shrink the input. b. Abstract away various parts into recursive steps. c. Break the problem into smaller tasks
Visualize the problem and the solution, on paper etc…
Work through the problem by hand, solving various cases until to recognize a pattern. Abstract this pattern away into a solution.
Talk to a Rubber duck