Skip to content

enriquenov/cracking-the-coding-interview

Repository files navigation

JavaScript Algorithms and Data Structures

Practice, practice and more practice!

======

Problem Solving Steps

Devise a plan for solving problems:

  • Understand the problem
  • Explore concrete examples
  • Break it down
  • Solve / Simplify
  • Look back and refactor

Understand the Problem

  1. Can I restate the problem in my own words?
  2. What are the inputs that go into the problem?
  3. What are the outputs that should come from the solution to the problem?
  4. Can the outputs be determined from the inputs? In other words, do I have enough information to solve the problem?
  5. How should I label the important pieces of data that are a part of the problem?

Explore concrete examples

  • This helps to double check that you completely understood the problem and what it's been asked.

Break it down

  • Write down a list of steps to solve the problem.
  • It doesn't have to be pseudocode.

Solve / Simplify

  • If you can't solve a problem right away. Solve something similar first (an easier version).

Look back and refactor

  1. Can you check the result?
  2. Can you derive the result differently?
  3. Can you understand it at a glance?
  4. Can you use the result or method for some other problem?
  5. Can you improve the performance of your solution?
  6. Can you thing of other ways to refactor?
  7. How have other people solved this problem?

Problem Solving Patterns

Master common problem solving patterns:

Some Patterns:

  • Frequency Counter
  • Multiple Pointers
  • Sliding Window
  • Divide and Conquer
  • Dynamic Programming
  • Greedy Algorithms
  • Backtracking
  • ... And many more!

Topics

  • Recursion
  • Searching
  • Sorting
    • BubbleSort
    • InsertionSort
    • SelectionSort
    • MergeSort
    • QuickSort
  • Data Structures
    • Singly Linked List
    • Doubly Linked List
    • Queue
    • Stack
    • Trees:
      • Binary Tree
      • Binary Search Tree (BST)
      • Tree Traversal:
        • Depth-First Search (DFS)
          • InOrder
          • PreOrder
          • PostOrder
        • Breadth-First Search (BFS)
      • Binary Heap:
        • Max Binary Heap
        • Min Binary Heap
        • Priority Queue
    • HashTables
    • Graphs:
      • Adjacency Matrix
      • Adjacency List
      • Graph Traversal:
        • Depth First Graph Traversal
        • Breadth First Graph Traversal

About

Practicing and solving problems from the Cracking the Coding Interview 6th Edition book.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published