Friday 2 November 2018

General Note on Competitive Programming

Competitive programming should be taken up like any other sport. It's highly intimidating, and it's very easy to be overwhelmed. One should understand when to look at the editorial, when to ask for hints and, lastly, when to look at other's code. 

The general sequence of steps is shown below: 

1. Examine the challenge carefully. Try to guess which approach should be used. 
2. Try solving the challenge using that approach. If you pass a few test cases, that means you are headed in the right direction. 
3. If some test cases are giving the wrong answer, download them and try them in your local or HR platform to see what the error is. Be aware that a test case being wrong is highly unlikely since many hackers have already solved the problems. Blaming the challenge is the wrong attitude to have and doesn't help you to learn. 
4. If you are completely clueless on how things are working, unlock the editorial and look at the solution. (DO NOT LOOK AT THE CODE) 
5. Now, build your own solution and, when you get accepted, look at the code given to see how much better/worse you were compared to the setter/tester. 
6. Lastly, a sport should be respected. Any attempt at cheating is harming only you. It's like any other sport: football, swimming, etc. To get better at it, you have to work hard by yourself, for yourself, and win. 
 


How to start with competitive programming 

Competitive programming is one of the most difficult sports and can be extremely overwhelming. It'll compel you to give up or look for an easy way out by checking for solutions on the internet that solve the challenge without programming the solution for yourself to see how the algorithm is working. 

There are two aspects to your learning. 

1. Participating in active contests (Online).
2. Learning newer and newer approaches (Offline). 

Participating in active contests  

By participating, you are putting your skills to the test. Your goals should be limited to coding your solutions as fast and as accurately as possible. Do not expect to discover a mind blowing approach to a difficult problem because, chances are, you might have never learned the algorithm. Great algorithms were not designed overnight, nor did anyone solve a path breaking research problem in a contest. 

Once you have participated, read the editorials to the problems that you thought you could have done but missed due to some error. Try to follow a select few great programmers and look at their code for problems you have already solved. See if their code is more elegant than yours. Many times, good programmers can solve with a better/faster solution if such a solution exists.


Offline Training 

Find yourself a good team or a partner to practice with and, if possible, a mentor to watch your back when you get extremely frustrated and stuck. (Write a message to me if you need help in this.) 

Learn a topic either by solving a random problem that you have no idea about or picking up a standard topic from any programming guide. 

A general sequence of learning concepts is:

1. Solving implementation and ad-hoc problems that just require a good grasp on your programming language and simple elegant code. 
2. Learn Data Structures. Get yourself familiar with Stacks, Queue, Arrays, Dictionaries, etc., and start using these structures to solve more implementation problems. 
3. Learn: Programming paradigms, Search algorithms, Greedy algorithms, Dynamic programming, and Divide and Conquer. By this time, you should be comfortable with terms like: BFS, DFS, backtracking, recursion, Top Down DP, Bottom up DP, Memorization, Sorting, Segment Trees, Red-Black trees, Binary Search Tree, AVL Tree, etc. 
4. After completing the previous steps, you are good to go for all general programming and can call yourself a beginner. Now, you can look at specific algorithms in Strings, Graph Theory, Mathematics, Game Theory, other advanced algorithms and data structures.

Monday 23 December 2013

Koramangala

A new life begins in Koramangala, Bangalore

Midnight street view of my street

It's been 2 months since I set foot in Bangalore. And that marks the beginning of a new life for me. It's all new because this is the time I wanted reform in life.

Backtracking Few months Life would be a bird in cage. Listening to people when will I start working, when is my college getting over. And I would just wonder what pleasure do people get with my success? and what depression does it bring with my failures. Then I realized no it's just this Facebook life that people are used to this mini-Page 3 life. Everyone is out there poking their nose trying to know what is everyone is up to. This was the time I decided to find a job near my home town Noida.

Moved to Hyderabad, after just a month long stay. It was too suffocating. And I was desperately in search of that independence and hence the job hunt went vigorous. Then Hackerrank happened :)






It was a regular weekend with mom and bro in Hyderabad. When I jokingly said don't irritate me i'll go Bangalore tomorrow. The same day I had applied to HackerRank (A platform for all coders and hackers ) Surprisingly enough next day I was giving interview in Bangalore.

And that's how my destiny brought me here. And life has never been so much in control before. Shit happens every other day but since i am the master of my life I can face it in my way. It's all beautiful.


Ek ehsaas hai zindagi

एक गहरा एहसास है ज़िन्दगी

कभी धुप कभी छाओ है ज़िन्दगी
चुप चाप मुस्कुराती है ज़िन्दगी

सदियों से लम्बी लम्हो से छोटी है ज़िन्दगी
मीठी यादों कि परछाई है ज़िन्दगी

रूठना मानना है ज़िन्दगी
जीती हुई बाज़ी हार जाना है ज़िन्दगी

धड़कते दिलों कि दास्ताँ है ज़िन्दगी
एक गहरा एहसास है ज़िन्दगी