Tips to solve DS and Algorithm related problems.

Whilst facing the interview, don’t jump into the solution of the problem immediately. Instead think of a data structure which can be applicable to solve the problem. Given below is the list of data structure and algorithms/approaches, you can think of and it is recommended to have all these on your tip as well –

  • Brute Force (For/while Loops) => Complexity (exponential, n^k, etc)
  • Sorting and Searching => Complexity ( n^k, n, logn etc)
  • HashMap, HashTable, HashSet => Complexity ( n, 1 etc)
  • Stack(LIFO), Queue(FIFO) => Complexity ( n etc)
  • Heap, PriorityQueue => Complexity ( nlogn, n, logn, etc)
  • Recursion and DP => Complexity ( exponential, n^k tc)
  • Tree, BST, Tree traversal, Tries =>Complexity ( n, logn, k etc)
  • Graphs (DFS {Stack}, BFS {Queue}, Topological) => Complexity ( E+Vlogv, V+E etc)
  • LinkedList, DoublyLinkedList=> Complexity (n etc)
  • Bitwise Operation  => Complexity (n, k, 1 etc)

Note* : In the online coding test, you may come across the situation in which you will have to write too many lines of code. Even these lengthy questions are asked to test your thinking whether you leave these questions or start wasting your time keeping other problems unattended. It’s not like that you don’t need to solve these lengthy problem but spare your time in the last only when all the other easy problems are solved.  Moreover, the point I would like to highlight is that in the face to face interview, you will always be asked the basic question having 15 to 20 lines of code max as this kind of f2f interview goes around 45 minutes min or 1 hour max.  Happy coding and learning 🙂