Problem-solving skill in coding is the ability to turn a plain-language question into clear steps a computer can follow. It is not talent. It is a habit you build with a fixed method and steady practice. Most students who say "I know the language but I can't solve problems" are missing the method, not intelligence.
This guide gives you that method, a daily routine and a six-week plan.
Why you get stuck
Students usually get stuck for one of these reasons:
| What happens | Real cause | Fix |
|---|---|---|
| You start typing and get lost | You did not plan the steps first | Solve small examples by hand before coding |
| You understand solutions but cannot write them | You read answers too early | Struggle for 20 to 30 minutes before a hint |
| You freeze on a new problem | You have not seen enough patterns | Practise one topic at a time |
| Your code works on the example but fails later | You skipped edge cases | Test empty, single and large inputs |
| You forget solutions after a week | No review | Re-solve wrong problems after 3 to 7 days |
Every fix in that table is something you can practise.
How to read a coding problem: the 5-step method
Use these five steps on every problem, even easy ones. They become automatic with time.
Step 1: Restate the problem in your own words. Write one sentence: "Given ___, return ___." If you cannot, read it again. Note the input type, the output type and any limits.
Step 2: Work two or three examples by hand. Use the given example, then make your own small one, then a strange one (empty input, one element, duplicates). Watch what you do in your head. That is your algorithm.
Step 3: Write the simplest correct approach. Do not aim for clever. A slow solution that is correct is a good first step. Write it as plain steps or pseudocode first.
Step 4: Improve it, if needed. Ask: "Where am I repeating work?" Often a hash map, sorting or two pointers removes a loop.
Step 5: Test before you submit. Run your own small examples and the strange ones from Step 2.
Pro tip: Say your steps out loud, as if explaining to a friend. If you cannot explain a step, you do not understand it yet. This also trains you for interviews, where you must think aloud.
A worked example
Problem: Given a list of numbers and a target, return True if any two different numbers add up to the target.
Step 1, restate: Given a list and a number, say whether some pair in the list sums to that number.
Step 2, examples:
[8, 3, 5, 1], target6givesTrue, because 5 + 1 = 6.[3], target6givesFalse. There is only one number, and you cannot use it twice.[], target6givesFalse.
Step 3, simplest approach: check every pair.
def has_pair_brute(nums, target):
for i in range(len(nums)):
for j in range(i + 1, len(nums)):
if nums[i] + nums[j] == target:
return True
return False
This is correct, but it checks about n × n / 2 pairs. For a long list that is slow.
Step 4, improve: while walking the list, for each number x we need to know whether target - x appeared earlier. A set answers that quickly.
def has_pair(nums, target):
seen = set()
for x in nums:
if target - x in seen:
return True
seen.add(x)
return False
print(has_pair([8, 3, 5, 1], 6)) # True
print(has_pair([3], 6)) # False
print(has_pair([], 6)) # False
Step 5, test with a dry run for [8, 3, 5, 1], target 6:
| x | target - x | seen before check | Found? |
|---|---|---|---|
| 8 | -2 | {} | No |
| 3 | 3 | {8} | No |
| 5 | 1 | {8, 3} | No |
| 1 | 5 | {8, 3, 5} | Yes, return True |
Notice the case [3] with target 6: we check 3 against an empty set before adding it, so the same number is never used twice. That edge case came from Step 2.
This is the same idea as the find a pair with a given sum and two sum problems on our site. Try them in your own language.
A daily practice routine
You do not need many hours. You need the same routine every day.
| Time | Activity |
|---|---|
| 5 min | Re-solve one problem you got wrong earlier, from memory |
| 30 to 40 min | One new problem using the 5-step method |
| 10 min | Read one other solution and note one idea you did not think of |
| 5 min | Update your practice log |
Your practice log needs four columns: problem name, topic, solved alone (yes or no), and the one idea you learned. Mark problems you could not solve alone. Re-solve them after three days, then after a week.
Common mistake: Watching a solution video, nodding along, and moving on. You will feel you learned it, but you will not be able to write it in a test. Always close the video and write the code yourself.
When to look at a hint
Use a fixed rule so you neither give up too early nor waste an evening:
- Work on the problem for 20 to 30 minutes using the 5 steps.
- If still stuck, read one hint or the topic name, not the full solution.
- Try for another 10 to 15 minutes.
- If still stuck, read the solution, close it, and write it yourself.
- Mark it in your log and re-solve it in three days.
Step 4 still counts as learning, as long as you re-solve it later.
Which problems to practise, in order
Start where loops and conditions are tested, then move to data structures.
- Number logic: digits, primes, factorials, GCD. Try check whether a number is prime.
- Strings: reversing, counting, palindromes, anagrams. Try check whether two strings are anagrams.
- Arrays: largest, second largest, rotation, duplicates.
- Hash maps and sets: frequency counts and lookups, like the example above.
- Sorting and searching, two pointers, stacks. Then follow our DSA from scratch topic order.
All of these are in our Problems section, with hints, approach and dry runs.
A six-week plan
| Week | Focus | Target |
|---|---|---|
| 1 | Number logic | 10 problems, 5-step method on each |
| 2 | Strings | 10 problems; re-solve 3 old ones |
| 3 | Arrays | 10 problems; one timed set of 2 in 45 minutes |
| 4 | Hash maps and sets | 8 problems; explain 2 aloud |
| 5 | Sorting, searching, two pointers | 8 problems; one timed set |
| 6 | Mixed review | Re-solve every problem marked "not alone" |
By the end, you should be able to solve most easy problems in 15 to 20 minutes and start medium ones with a clear plan.
Taking this into tests and interviews
In an online test, the timer changes everything. Read all problems first, get a working solution before an optimal one, and test edge cases before submitting. Our guide to clearing online assessments covers the timing in detail.
In an interview, the 5 steps become your conversation: restate the problem, ask about limits, share the simple approach, then improve it. Interviewers value clear thinking as much as the final code. For common questions, see our DSA interview questions.

