Step by Step guide on how you can be a green coder, for newbies

Revision en2, by yozaam, 2020-10-22 11:44:41

This is my opinion and of course, there will be many different ways to do something so read it if you want to know what I did...

To be green we need to be very comfortable with ad-hoc problems these are problems where you don't need to use any data structures (heap,tree etc) or algorithms (dp,binary-search etc) div2A is always ad-hoc, div2B(sometimes adhoc) is also needed to be green most of the time(so if we clear A in 15 minutes, we spend the time on remaining time on B)

The problems are never the same, but the way we approach them is similar
so I recommend going through the div2A problems here blog problems list (thank you! mostafa.saad.fci) after solving half of the problems, I stopped coding them and instead just tried to reach the point where I knew exactly what I wanted to code and then read the editorial to verify

Read/See on youtube lots of code everywhere understand all editorials!!

You should be able to solve div2A problems after reading/coding all the problems from div2A in that list (around 80 of them)
&& giving every div3, educational, atcoder beginner contest, div2, codechef for few months

Some tips from me: ->Try to ignore the irrelevant information: like names of people, berland, etc
->Figure out exactly what is asked
->Get your paper and pen and draw the example cases
->Once you can solve any problem as a human, i.e. take an input and be able to get the output
->make your thought process into an algorithm
->very often it can become a single formula or few if-else statements
->later you can worry about optimization like instead of doing while(true)a-=26 until you reach your desired value, you can just do it like a-=26*(b-a)/26 by a particular value

For div2B: It is usually possible to solve these with a specific realization after drawing enough examples and then thinking of your strategy when solving these as a human
Very often B or C is a greedy algorithm find min/max, or else you need to return any of the correct solutions when you see any, you should think of the easiest examples and solutions(ignore samples sometimes) and think about how you can convert those into an algorithm (try to come up with the simplest/obvious method)

For div2B/C where it is an array and you have no idea what to do:
Try to sort the input, apply a hashmap for frequencies/positions, if it is binary string, convert it to run length encoding, eg. 0001111000111 -> (0,3),(1,4),(0,3),(1,3)
The problems where two players are playing a game -> play the game with yourself on paper

For the rest, I am yet to learn the strategies but often in the questions, it helps me to make imaginary functions that you call and implement those later, all the best :D

Tags #pupil, #newbie, #beginner, green

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English yozaam 2020-10-22 11:44:41 10
en1 English yozaam 2020-10-22 08:18:28 2927 Initial revision (published)