I am looking for some helpful tips so that i can apply them when i get struck while solving a problem.
Take a chill pill…cool down your mind and remove frustration first. After that, question yourself is the gap between AC and my logic is beyond mine knowledge ?? if yes then skip it else you can give it one more try without getting frustrated and if after that i will not get AC, then without wasting time checkout the editorial
I look at the editorial and call it a day.
If its has been too long, then I walk off the screen and do something else until I can concentrate. Then I try to find out what exactly the question wants and how far down the question have I gone till now. Mentally try and think of all corner cases that I might be leaving behind. Tweak the code a bit. Hit submit.
Rinse and Repeat.
I scratch my head, roam around the house, feel like breaking the laptop, but then realise its just a problem and then sleep like a dog lol
If it’s a minor bug, but the approach is correct, mind.clear(), delete the code.cpp, start coding from scratch again, suitable for problems like TTUPLE
If you’re stuck in the sense that you’ve ran out of ideas, just take a look at the editorial, most CPers suggest, read maybe a line or 2 from the editorial, you’ll get a hint, and the solution might strike in your mind.
If a lightbulb doesn’t glow, read the full editorial, and look at other people’s submissions. Reach out to a friend for help, or ask in the forums.
If the contest is live, and you don’t seem to be able to solve the problem, there might be one of the two reasons:
Lack of knowledge: consider the problem Dragon Den, from recent Long Challenge, it requires knowledge of HLD, if you knew this the problem is quite simple. But when you don’t know HLD, you could try to reduce the original problem, to a standard problem, this one reduces to “path queries on trees”, and Google searching this will get you to HLD tutorials and articles. You could learn the concept, and try to apply it, of course, when the contest is Long.
Lack of practice: say the question is simple, something to do with counting subarrays satisfying a particular property, such questions don’t need any special knowledge of algorithms or complicated data structures or anything, simple approaches like prefix sums or two-pointers work here, but you get stuck if you’re not so familiar with these kind of questions, in which case, you need to practice these.
So true about TTUPLE. I tried to debug my old code 10 times, but it only gave WA. I wrote a new code, and it passed in one go!
P.S. However, it’s bad practice wipe out and start again. In questions like TTUPLE it’s fine, but in general it’s good to be able to debug your code.
See the Editorial and after seeing the solution I cry for some time thinking of why I was not able to came up with that solution: Xd
i just post the latest submission and sleep. if its not the time to sleep i just go through some submitted codes and editorial. most of the time i skip questions. i still have to do this.
It happens many a times with me. I honestly just leave my laptop for a couple of minutes and lie on the bed thinking of ways to solve without actually coding it. And the fact is this: frustration is always associated with an obstacle, and an obstacle is associated with growth because we learn by analysing and solving it. Of course, I’ll look at the editorial after a certain period of time, but the thinking is what pushes the boundaries, right?