/Technical-Interview-Prep

My solutions to Cracking the Coding Interview, as well as any other practice code I use for technical interview prep.

Primary LanguageJava

Topics Covered

(* Indicates a problem I struggled to implement correctly and need to review later)

Cracking the Coding Interview

Chapter 1 - Arrays and Strings

  • 1.1 - Is Unique
  • 1.2 - Check Permutation
  • 1.3 - URLify
  • 1.4 - Palindrome Permutation
  • 1.5 - One Away -> See generatePermutations and printNumbersWithBase under Helpful_Problems for examples of the naive case.
  • 1.6 - String Compression
  • 1.7* - Rotate Matrix
  • 1.8* - Zero Matrix
  • 1.9 - String Rotation -> Had difficulty visualizing what a rotation was, becomes easier once able to visualize. Also see isSubstring under Helpful_Problems.

Chapter 2 - Linked Lists

  • 2.1 - Remove Dups
  • 2.2 - Return Kth to Last
  • 2.3 - Delete Middle Node -> I overcomplicated this one on my first attempt. This is as simple as finding the node before the one to remove, and changing its pointer to the one after it.
  • 2.4 - Partition
  • 2.5 - Sum Lists
  • 2.6 - Palindrome
  • 2.7* - Intersection -> The O(n) time and O(1) space solution to this problem was a little tricky, worth looking at again.
  • 2.8* - Loop Detection -> This one requires you to know the "Tortoise and the Hare" algorithm for its best solution. I would recommend reviewing this algorithm in detail, especially how to return the index of the start of the cycle.

Chapter 3 - Stacks and Queues

  • 3.1* - Three in One -> This one is simple in theory, but difficult to fully implement, because there are alot of areas where you can get out of bounds exceptions.
  • 3.2* - Stack Min -> Tricky at first, but simple when you realize that additional space complexity is required.
  • 3.3 - Stack of Plates
  • 3.4 - Queue via Stacks
  • 3.5* - Sort Stack
  • 3.6 - Animal Shelter

Chapter 4 - Trees and Graphs

  • 4.1 - Route Between Nodes
  • 4.2 - Minimal Tree
  • 4.3 - List of Depths
  • 4.4 - Check Balanced
  • 4.5 - Validate BST
  • 4.6 - Successor
  • 4.7 - Build Order
  • 4.8 - First Common Anscestor
  • 4.9 - BST Sequences
  • 4.10 - Check Subtree
  • 4.11 - Random Node
  • 4.12 - Paths With Sum