Basic data structures you need for coding interviews
Updated: Jan 17, 2021
Hey y'all ! (I'm trying to go the Texan way after it came up in a discussion today with a teammate who's from there :) )
I want to list basic types of Data Structure that you need to know of before you think you are ready for an interview. And I'll share one very easy leetcode problem against each one to test your basic knowledge!
(After this, do read the next post on Advanced data structures !)
What should you practice? Being able to navigate in any sort of manner in an array using a loop. Being able to do the same in a 2D array. Try doing this - https://leetcode.com/problems/spiral-matrix/ If you can't do this, you aren't ready at all. No pressure.
What should you practice? Being able to slice and dice the string, and navigate through it. Try doing this - https://leetcode.com/problems/split-a-string-in-balanced-strings/
3. Linked List
What should you practice? Being able to traverse, insert, play around with pointers. (Java lovers, please remember using an inbuilt data structure DOES NOT COUNT! ) Take a shot at this one - https://leetcode.com/problems/merge-in-between-linked-lists/
What should you practice? Oh there are so many things here. But let us focus on traversing the tree. So priority should be pre/post/in order traversals. Also, how do you run Breadth First Search (BFS) or Depth First Search (DFS) on a tree? Test your skills here - https://leetcode.com/problems/symmetric-tree/
A specialized problem set here would be related to Binary Search Trees. Probably try the following - https://leetcode.com/problems/range-sum-of-bst/
What should you practice? Being able to do a BFS or DFS on a graph. And figuring out how to store a graph (there are multiple ways). To practice - Write a program to run BFS and DFS recursively.
What should you practice? They are similar but yet so different. Probably the previous question already got you thinking about these (iterative BFS/DFS). But if not practice the following for a good start - https://leetcode.com/problems/implement-queue-using-stacks
What should you practice? You should practice knowing when NOT to use these :) I've seen people use these in every question, assuming they are the universal solution. But that's not the case. These cost extra memory! They try to get you O(1) time, but do you know how? Because if you use this in an interview, I'll check if you know how they implement themselves. So be careful. Take a look at the following - https://leetcode.com/problems/happy-number/
Let me know what you thought of those problems! I was sneaky and put a few algorithms in there, too :) But hey, it is all for a good cause.