I am able to solve only 3 or 4 problems in long contests. I don’t know much algorithms, so it is hard for me to solve more problems.I have solved many easy problems on codechef. Now, solving medium level problems on codechef for sometime, and them hard ones, a good way to learn algorithms or should i learn an algorithm and then do questions related to it? or something else?
Take a look at it…
You can do this course by commonlonge which has been prepared by some great competitive programmers-
Also you can read the book on Competitive programming by steven and felix halim
The most important part to learn algos is take part in as many contests as you can and go through the editorials of questions that you couldn’t solve in the contest(Give it one more try before going to editorials.)
Hope it helps you