Skip to content

praveenkesarwani/Interview-Prep

Repository files navigation

Data Structures and Algorithms

This repository contains data structures and algorithms concepts and questions useful for interviews

Table of contents

  1. Arrays
  2. LinkedList
  3. Trees
  4. Hashmap&Heap
  5. Stack
  6. Queue
  7. Recursion
  8. Graph
  9. Advanced DS/Algo
  10. Greedy

Tips to Consider

If input array is sorted then

  • Binary search
  • Two pointers

If asked for all permutations/subsets then

  • Backtracking

If given a tree then

  • DFS
  • BFS

If given a graph then

  • DFS
  • BFS

If given a linked list then

  • Two pointers

If recursion is banned then

  • Stack

If asked for maximum/minumum subarray/subset/options then

  • Dynamic programming

If asked for top/least K items then

  • Heap

If asked for common strings then

  • Map
  • Trie

Else

  • Map/Set for O(1) time & O(n) space
  • Sort input for O(nlogn) time and O(1) space