Recently, I have started solving problems consistently but faced a major issue, that I am unable to make logics more efficiently. Like, whenever I starts solving some problem, I read it twice or thrice then heading towards making the code, which I am good at. But, after solving whenever I see the tutorials or the solutions, I often finds myself making a too much large codes, which is not even needed. Just a small piece of code with a little bit of conditions on it, and BOOM! code runs.
I don't know where am I lacking, either I should focus on complex mathematics, so that I could figure out loop holes (LOL), or I should work on how should I find the most easiest way to solve the problem. However, its been 2 years I've started programming and solved many problem either on HackerRank, or some random questions from Books, but not when i have started on CodeForces, I sometimes feel like I haven't practiced anything till now.
Although, finding these difficulties is common for a new programmer, but now I want to know how can I improve myself and how can I make my codes or solutions more precise and efficient which takes less time, space, and most concerning — lesser lines of code.
If the reader have some tips, tricks, or some suggestion then do let me know, as now I am eager to learn more of them.
I'm probably the wrong person to answer this, but I'll tell you what my senior told me.
Practice.
It seems like you code first and think later. Try reversing that process. Start by noting everything you want to accomplish, prepare some test cases, including edge cases, and then write the code.
Focus on the types of problems you excel at and solve those.
One last piece of advice: optimize your solutions. Don’t just solve a problem once. After a day or two, if you still don’t fully understand the solution, go ahead and code it. You’ll notice your skills improving over time!
why am i good at solving problems?
A wise man once said:
Stop doing competetive programmingSolve problemsSource: https://codeforces.net/blog/entry/47516
Just solve more problems, the more problems you solve, the less issues you will encounter.