Interview of a Competitive Programmer

“This is too hard”
“I dont know where I should start! All the problems are mind boggling”
Competitive programming is a way out for aspiring developers working in colleges to get awesome jobs and build a career in the software industry.
Especially in this competitive market where the disconnect of college education and industry knowledge is miles apart.
Mayank, whom I met earlier on LinkedIn, (Mayanks Hackerrank Profile), is a awesome competitive programmer and an awesome guy, and was kind enough to share his exprience in the same in this interview.

So, without further ado, here’s the interview –

Aiyush – How and when did you start with competitive programming?

Mayank – I started this when I was in 2nd year of my B.Tech.

Few months before, there was a coding practice test organized by my seniors.

I had also participated in that test but was unable to attempt even a single question.

All the questions were totally flowing over my mind, have never thought that coding is that much difficult.

Then after my first year was completed, in summer, I started competitive coding at hackerrank.

Everyday seems like failure as even easy questions ware unexpected and wasn’t able to figure out solution.

But, after so many hard practices, participating in various competitions and sleepless nights, I win over it.

Aiyush -Thanks! Awesome answer! A few more questions 😛

Which data structures do you use most often when participating in competitions?

Which topics like dynamic programming, greedy algorithms etc have given you the most benefit in terms of solving problems?

Mayank – There aren’t any specific data structure which I mostly prefer as it is completely problem dependent 🙂

Like one can’t use arrays in place of segment trees for queries, for storing path mappings for a spanning tree, it would be so naive to use 2D array as it will be sparse and thus memory inefficient so adjacency list should be preferred , etc.

Now talking about topics, solving pure implementation problem i found to be a good prior as it reflects the ability of an algorithm designer without knowing any particular set of algorithms.

However there are also some nice topics like string manipulation, graph theory, bit manipulation, greedy algorithms.

Lastly I think understanding some DP problems is necessary first,looking at that how it’s solution is working and then proceeding towards finding a DP solution for other problems .Having overlapping sub problems is i think , an algorithm designer will benefit from, most. 😀

Aiyush – Last question – how did practicing competitive programming influence your style of writing code?

And what is your advice to beginners in this domain?

Mayank – Whenever someone has to design a logic for a given problem, then the best way to proceed is to develop a brute force solution and then do necessary optimization as per requirement.
But after practicing competitive programming, one can use the gained domain knowledge during problem solving in real life and it saves time from starting with naive brute force.
No matter what kind of problem someone is solving but can definitely come up with an intuitive optimized solution because he/she can now clearly identify the search space and the constraints where logic can fail.
That’s what differentiates a naive programmer over a competitive programmer.
So, in short 🙂 , competitive programming enables me to write best code, both in terms of robustness and optimization.
Advice to beginners: Coding is easy but designing logic and algorithm is really challenging but not impregnable.
Whenever you have a feeling – “I can’t, now i should back off “, just think that 95% people backoff at this stage and only 5% advance to next stage, so ask from yourself, where should you stand? 😀
It’s a good rule which i always follow and believe me, I’m really greedy to stand always in 5% no matter what i have to do.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s