Are you preparing for Algo / DS interviews?

Here are some tips from my experience which can help you crack your interviews:

🧵👇🏻
I've conducted a lot of interviews and have gone through many interviews myself.

In this thread I'll try to cover some of the basic things which you need to prepare for before your Algo / DS interview rounds.

Let's start!
1. Tree Traversal:

Tree traversals are used heavily in the industry in software developer job interviews. So you should be aware of:

- inorder
- preorder
- postorder
- BFS
- DFS
- Time complexity to traverse a binary tree, binary search tree etc.
And you should know how to do these recursively and iteratively.

Learn how to use stacks and queues to traverse a binary tree in preorder, postorder and inorders traversals.

When you're doing these recursively focus on what the base case should be.
2. Recursive vs Iterative:

Recursion is an important concept to learn and can be tricky sometimes.

For some category of problems writing code can be very easy if you figure out the base cases.
But recursion sometimes takes exponential time complexity. So you should know how to optimise a solution using iterative approach.

For ex: Check how to generate fibonacci numbers using iterative approach and recursive approach and the respective time complexities.
Remember that sometimes all that interviewers are looking only for is a recursive approach since iterative approach can be complex and tricky to solve in the given limited time for certain problems.

Keep that in mind.
3. Stacks and Queues:

These are commonly used and very handy. One common question is given a string of parentheses, check if it is valid.

Using a stack makes it really easy to solve this problem.

You can use stacks and queues for iterative tree traversals too!
4. Object Oriented Programming:

OOP concepts are very important in software engineering and you should know the below concepts.

- encapsulation
- abstraction
- inheritance
- polymorphism
And you should know thoroughly how to create classes, private & public methods etc in any language of your choice without Google.

Sometimes using classes can simplify solving a problem at hand.

For ex: A tree node can be represented as a class like this in Python:
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
5. Hashmaps:

This is another very important and commonly used DS in solving problems.

Since lookups in hashmaps can be done in constant time, we can tradeoff some space to solve a problem in better time complexity.

Hashmaps are very helpful in these scenarios.
More often any optimal solution involves using these important data structures:

- stacks
- queues
- hashmap

One common interview question is 'Two Sum'. Checkout how to solve this using a hashmap.
6. Strings:

Strings are another category of most asked interview questions. Know the basic operations on strings in your language of choice:

- check if a string is a palindrome
- check if two strings are anagrams of each other

etc.
7. Dynamic Programming:

This is another commonly used approach to solve problems optimally.

In DP, the basic concept to learn is 'memoization'. Basically the idea is to store the precomputed values in a cache so that it can be reused later.
DP can be very intimidating in the beginning. Know that you're not alone. A lot of people struggle with DP problems during interviews.

For many of us either we get it or not during an interview. The only way to get better at it is by practising.
DP problems are generally very tricky and if you solve a given problem using DP, you will really stand out.

So practise!
Finally practise a lot of question by solving and writing code in any language of your choice. You should know how to use basic DS in that language.

Once you solve a problem on paper, you're expected to write bug free code on an editor.

All the best!
If you like this thread make sure you retweet it so that many people benefit from it.

Finally consider subscribing to my blog where I generally write detailed articles on topics like:
- freelancing
- software development
- AWS
- SaaS
etc http://sunilkumarc.in 
You can follow @sunilc_.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.