Competitive Programming & DSA
No suprise, this by far is the most important part that you need to focus on. Don’t start at the last minute, and try to inculcate the habit of solving questions and discussing with your peers early on.
- Give contests regularly! Codeforces is the best platform for upsolving as well as giving contests. Many companies known for difficult tests often give direct restatements of the problems from here. Codeforces blogs on topics are great too!
- In the final month leading to placement OAs, I also started giving LeetCode, AtCoder, and Codechef contests. I absolutely love AtCoder Beginner contests, have grown acustomed to the LeetCode ones, and hate Codechef. But they all have their own charm, and you should try them all to see which one you like the best.
- The CSES problem set is a gold mine that is often overlooked. I personally used it in two manners:
- Solving it periodically to ensure that I know the basics of a topic. Many questions from the same are used as subproblems in other problems, and the general solving techniques that I picked up from here helped me a lot. There have been many a times when I was unable to solve some LC questions, and then found articles and solutions of the same building on some CSES problems.
- Resubmitted some of the common problems before the online assessments to ensure that I my brain has not rotted from using all the templates and Co-Pilot suggestions during the regular CP contests.
- CP Algorithms is my go to resource for templates & intial understanding of a topic. The explanations are crystal clear, all accompanied by code snippets, common extensions of the problems as well as recommened problems. I would not recommed using it as a question source, but definitely for the theory and implementation snippets.
- The infamous Dynamic Programming Atcoder List is a must read for all the DP problems. I would recommend solving the problems on your own first, and then looking at the solutions to see if you can improve your code or if there is a better way to solve the problem. It is probably the best curated introductory list of DP problems of the most common types.
- This is a list of Leetcode Problems that I had curated throught my placements. Some of these problems have been directly asked in OAs, and others are my favourite because of the concepts they teach. They are strictly more from a CP point of view and not DSA, so they may not be entirely useful for interview preparation.
Core Computer Science Concepts
These concepts take the most time, and are often the deciding factors in a low-medium difficulty online assesement where a large majority of the students are able to solve the problems. My two cents: don’t skip these topics or keep them for the last. Learn them early on, and maintain conscise notes. Then as the placement or intern season approaches, make a habit of spending 30-45 minutes daily to solve MCQs related to these topics.
GFG is probably the only resource you need for these MCQs. It is very common for the companies to directly pick questions from here, and the explanations are also very good.
Here are also some conscise notes that I started maintainging as I solved these MCQs, as well as from the questions I saw in my online assements and that of my seniors. I have no plans of updating them, and they probably won’t make any sense if you haven’t studied the topic first. But if you have, they might be a good refresher and help you in remembering some important or lesser known points, and getting those ‘tricky’ questions right.
CPP Topics
When preparing for interviews, these are some common topics that I found to be the favourite amoung interviewers, specially for C++ developer roles or low level system roles. Learn CPP is a great resource for these topics and learning C++ nitigrities in general, but it you are short on time (like I was), these are some topics that you should focus on:
-
- How to figure out if a
void *
pointer is pointing to an integer or a character array? - How to figure out if a
void *
pointer is allocated on the stack or the heap?
- How to figure out if a
-
Smart Pointers & Move Semantics in CPP
Quick Notes
-
How do these work under the hood and why do we need them?
We need smart pointers because raw pointers are error prone and can lead to memory leaks. Smart pointers are objects that manage the memory of a pointer, and automatically free the memory when the object goes out of scope. They are also exception safe, and can be used in containers and classes.
-
std::unique_ptr
- Allocated on the stack, and eventually calls
delete
on the pointer when it goes out of the scope. - The copy assignment operator and the copy constructor are deleted, and thus it can’t be copied. You need to use
std::move
to transfer the ownership of the pointer. - Smart enough to differentiate between scalar delete or array delete, but is advised to use with
std::vector
orstd::array
instead of raw arrays. - Use
std::make_unqiue
to create astd::unique_ptr
instead of usingnew
directly. It calls the constructor of the object and returns astd::unique_ptr
to the object. This can lead to better exception safety and is more readable.
- Allocated on the stack, and eventually calls
-
std::shared_ptr
- Keeps track of how many
std::shared_ptr
are pointing to the same object, and deletes the object when the laststd::shared_ptr
goes out of scope. - Always make a copy of an existing
std::shared_ptr
if you need more than onestd::shared_ptr
pointing to the same resource, otherwise each of them might think that it the sole owner, and drop the memory when it goes out of scope. std::make_shared
is also available, and is recommended to use instead ofnew
for the same reasons asstd::make_unique
.- Internally, it uses a control block to keep track of the number of
std::shared_ptr
pointing to the same resource, and the resource itself. The control block is allocated on the heap, and the resource is allocated on the heap as well.
- Keeps track of how many
-
std::weak_ptr
-
Difference between references and pointers in C++. When to use which and how they affect the safety as well as the usability of the code?
-
Multithreading in C++
- Write a web-crawler using multithreading in C++ that can crawl multiple pages at the same time. The crwaler should work in a BFS like manner, and we should be able to configure the maximum depth of the crawler.
We have assumed the existence of a
HtmlParser
class that has a methodgetUrls
that returns a list of URLs on the page. Thecrawl
method should return a list of all the URLs that the crawler has visited.
-
PS
Computer networks in also usually included in CS concepts, but I decided to skip them in the interest of time. A very few companies ask questions from this topic (like Cisco
) and for very specific roles (like Network Engineer). You might want to read about them if you are interested in such roles.