What do I do when I am spending hours to understand a solution

I am a university student and I am actually enjoying competitive programming despite my performance flaws. Time is very limited in my schedule and sometimes looking at solutions take me the LONGEST time to understand. For example, it took me 2 hours to understand the solution to TREEVERS.

Long story short, I am simply asking am I biting more than I can chew.
Because I would love to spend all this time to do competitive programming YET, what about my university classes? How much energy do I put into those classes versus competitive programming. Sometimes there is overlap, but sometimes I don’t see it. For example in my algorithms class we use the famous Cormen textbook and my professor is very math based. All these different sorts of proofs etc. that I don’t see myself using. UNLESS I am wrong! I always think of Errichto or Petr, and Tourist, and I can bet that they would KNOW how to do these complicated math problems, etc. and I try to use that as a motivator for me to understand the book.

Sorry for being confusing, all I am saying is I have limited time. Should I spend 4 hours to understand this Cormen book (and all the exercises) or should I spend 4 hours to do competitive programming.


You should do competitive programming . Reading a book dosn’t work at-all.
Practicing a particular algo from a questions makes you never forget that algo but if you study from a book you might forget it in less than 1 week.
Practice will make you learn all the algorithms. :smiley:


Your university grade in the algorithms course should be A+/A if you are a solid competitive programmer. You don’t need to do both simultaneously. Work on the Math first, proofs are very much needed. You’ll need to prove the correctness of your algorithms for CP problems (if not to others, to yourself) before coding it. Start CP properly next sem or in the winter break, with a solid base in Math. While you are focusing on the university course go beyond its curriculum and learn more interesting algorithms and mentally solve a few CP problems for fun [You needn’t code it, just confirm with the editorial].

CP is more application-based, you’ll see such weird uses of binary search you’d be flabbergasted. And also don’t directly try to understand ppls solutions. First, get the editorial then look through ppls solution for a nice impl or better algo. The more algorithms you know more quickly you can grow in CP.

I don’t think you are biting more than you can chew, you are just biting wrongly. Most times when a solution takes too long to unravel itself in your head is when you don’t know some prerequisite algorithm or data structure involved.

Try problems you know pre-requisites of first. Once you are confident, then learn more stuff unlocking more problems. Neither BFS nor DFS works balance is needed.

I’d recommend practice on codeforces for anybody who is looking to learn things fast, most things in CP I’ve learnt were from CF. Then I came here to show off some acquired skills :wink:

Codeforces is awesome for all levels of ppl. Just use their discussions and comments wisely, they don’t appreciate ppl asking qns that may already have standard uninteresting answers. Their frequency of short contests is good so that is nice for ppl for want to learn a lot fast. Very quick editorials, balanced question set for each contest based on the Div, nice alternate approaches in the comments etc…


My grade in my college is pretty good, Try to solve questions that teach you a deep concept. . Maths is almost everywhere, so get a good grasp on it.Try these questions (my favorite :stuck_out_tongue:)

  2. LAPD

Even if u take 4 hours. You’ll feel satisfied and happy when u get that green tick. But there’s one catch, solve it on your own, without looking at solution or with friends, when you’re practicing. I know some people who solve every question even of long challenge in group :joy: So solve alone, and you’ll get better.

P.S - I’m still a learner so these are my personal opinions, subject to change😛


So u recommend solving codeforces problem set in sorted order? :upside_down_face:

Different strategies work for different ppl. What I did as a noob was pick some div2 contest. Try it as a virtual contest, solve one/two more problems than I was able to solve in the round. Learn what crucial observations the problems required that I didn’t get to or took a long time to get to. If the next one/two questions in the round req some more algos and data structures, Great! Time to level up on skill, learn those things again through codeforces blogs most times, they are awesome (Just believe me). For some topics I used multiple sources like Codeforces Blogs/cp-algorithms.com (emaxx)/ TopCoder/ Misc. Then find problems on those topics (generally given in the corresponding Codeforces blog), solve them. Congrats now you know more. Give more contests. Solve More. Learn More.

You’ll figure out your weak topics, these will be those you learnt but didn’t do enough targeted practice on. FInd another list of problems for the same on CF blogs and solve as much as possible or prune the problem set based on tags. And one more thing while solving in the huge codeforces problem-set, don’t waste time solving problems largely below your rating. Have a range of rating you are around, and try to upskill by solving qns in this range. Either you’ll learn something new or gain some impl exp to help your speed. If more of the latter happens, you are almost guaranteed of getting a rating increase in the next contest, so your window of practice qns moves to nicer qns.


Thanks man…will keep these in mind :ok_hand::slightly_smiling_face:

Some bonus for you :slightly_smiling_face:
Here is a significant portion of blogs/problem lists I read/solved some problems from last summer

DP on trees
Sqrt Decomposition
Convex Hull Trick [This isn’t convex hull, its a DP optimization]
Graphs Problems [Morass’s comment here is GOLD]
All problems topic wise [Morass]
Bitmask-DP ham-path
Sum over Subsets DP
Randomly came across this
Using FFT for some recent(back then) long challenge problem

In general Codeforces comments section is a gold mine of nice problem suggestions, alternate solutions and some nice humor.


Thanks soooo much :heart_eyes::heart_eyes::heart_eyes: you’re too good bro.