When I started, I would spend 2 hours solving a single problem.
Spend 1-2 weeks on a topic, learn the data structure and basic algos behind it, then switch to another, and return to the previous topic again but later. Start with strings/arrays, move to linked lists, trees, and graphs, revisit topics over and over, learn dynamic programming concepts solve 1-2 weeks again.
Read the problem, repeat it, understand it. Don’t immediately jump into coding!
Understand inputs and outputs. Draw some examples on paper.
Clarify requirements, ask clarifying questions, and understand constraints (edge cases). Example questions: Is it ASCII or Unicode? What is the max value? Is there a difference between capital letters and small letters?
Check my questions lists here.
Think about the solution in your mind. Divide problems into sub-problems. Come up with different ideas (ask whys, think about trade-offs, solve simpler versions, imagine helper functions - go from high level to low level).
Evaluate the complexity and trade-offs.
Think of a better alternative solution.
Write code on paper.
Debug your code on paper and test with new corner case inputs.
Write code. Write clean code.
Write tests. Positive, negative, with edge-cases.
More to read: