/fe-dsa

Leetcode problem solutions implemented in TypeScript

Primary LanguageTypeScript

Data structures and Algorithms in TypeScript

Data Structures

  1. String
  2. Array
  3. Hash Table
  4. Linked List
  5. Stacks & Queues
  6. Trees
  7. Graphs

Algorithms

  1. Recursion
  2. Sorting
  3. Searching
  4. Dynamic Programming

Patterns

  1. Two Pointers
  2. Sliding Window
  3. Matrix Treversal
  4. Arrays
  5. LinkedList
  6. Tree BFS Treversal
  7. Tree DFS Treversal
  8. Binary Search

General Tips

  • If input array is sorted then
    • Two pointers
    • Sliding window
    • Binary search
  • If given a tree then
    • DFS
    • BFS
  • If given a linked list then
    • Offset pointers
    • Fast & slow pointers
  • If recursion is banned then
    • Stack
  • If must solve in-place then
    • Swap corresponding values
    • Store one or more different values in the same pointer
  • 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