You cannot become a strong developer by only reading books or watching video lessons. Real programming skill is the art of analysing a problem correctly and turning it into a precise algorithm a computer can follow.
In this article we look at how to approach any programming problem, which mistakes are the most common and how to avoid them.
1. Read the statement slowly and completely
Many beginners skim the statement and rush straight into writing code. That is one of the biggest mistakes.
- Input: what format is the data in? Are the numbers integers or reals? Can a string contain spaces?
- Output: exactly how must the answer be printed? Is there a required precision after the decimal point? Does letter case matter?
- Check the examples by hand: work through the sample tests with pen and paper. If you do not understand how the sample answer was obtained, you will never be able to explain it to a computer.
2. Pay attention to the constraints
Every problem has a Time Limit (for example, 1.0 second) and a Memory Limit (for example, 256 MB). The size of the input value $N$ tells you the time complexity your algorithm needs:
- $N \le 20$: exponential solutions ($O(2^N)$ or $O(N!)$) pass — for example, brute force or recursion.
- $N \le 1,000$: quadratic algorithms ($O(N^2)$) work — for example, nested loops.
- $N \le 10^5$ or $10^6$: you need linear or log-linear algorithms ($O(N)$ or $O(N \log N)$) — for example, two pointers, binary search, sorting.
- $N \ge 10^9$: only an analytical formula or an $O(\log N)$ mathematical solution will do.
3. Do not forget the corner cases
Your code may work on simple tests, but a Wrong Answer (WA) is most often caused by corner cases:
- $N = 0$ or $N = 1$;
- negative numbers and zeros;
- very large numbers (overflowing a 32-bit
intand needinglong long/BigInt); - empty strings or arrays with a single element.
4. Interpret the verdicts correctly
On ALGOR a submitted solution can get one of several verdicts:
- Accepted (AC): all tests passed.
- Wrong Answer (WA): the program ran, but your output did not match the expected answer.
- Time Limit Exceeded (TLE): your code ran longer than allowed — optimise the algorithm.
- Memory Limit Exceeded (MLE): the memory limit was exceeded — reduce your array sizes.
- Runtime Error (RE): the program crashed while running (for example, division by zero or going out of array bounds).
Conclusion: start practising right now!
The best way to cement theory is to solve problems regularly. The Problems section of ALGOR has hundreds of tasks sorted by topic. Make it a firm habit to solve at least 1–2 problems every day!