tvl-depot/scratch/deepmind/part_two/todo.org
William Carroll ae9e83f5d7 Solve InterviewCake.com's mesh-message problem
Write a function that returns the shortest path between nodes A and B in an
unweighted graph.

I know two algorithms for finding the shortest path in a *weighted* graph:
- Use a heap as a priority queue instead of the regular queue that you would use
  when doing a BFT. This is called Dijkstra's algorithm. You can also use
  Dijkstra's algorithm in an unweight graph by imaginging that all of the
  weights on the edges are the same value (e.g. 1).
- Map the weighted graph into an unweighted graph by inserting N nodes between
  each node, X and Y, where N is equal to the weight of the edge between X and
  Y. After you map the weighted graph into an unweighted graph, perform a BFT
  from A to B. A BFT will always find the shortest path between nodes A and B in
  an unweighted graph.

I had forgotten that a BFT in an unweighted graph will always return the
shortest path between two nodes. I learned two things from InterviewCake.com's
solution:
1. I remembered that a BFT in an unweighted graph will return the shortest
   path (if one exists).
2. I learned to use a dictionary to store the edge information and then
   back-tracking to reconstruct the shortest path.
2020-03-20 16:49:49 +00:00

2.2 KiB

Array and string manipulation

DONE Merging Meeting Times

DONE Reverse String in Place

DONE Reverse Words

DONE Merge Sorted Arrays

DONE Cafe Order Checker

Hashing and hash tables

DONE Inflight Entertainment

DONE Permutation Palindrome

DONE Word Cloud Data

DONE Top Scores

Greedy Algorithms

DONE Apple Stocks

DONE Highest Product of 3

DONE Product of All Other Numbers

DONE Cafe Order Checker

DONE In-Place Shuffle

Sorting, searching, and logarithms

DONE Find Rotation Point

TODO Find Repeat, Space Edition

DONE Top Scores

DONE Merging Meeting Times

Trees and graphs

DONE Balanced Binary Tree

DONE Binary Search Tree Checker

DONE 2nd Largest Item in a Binary Search Tree

DONE Graph Coloring

DONE MeshMessage

TODO Find Repeat, Space Edition BEAST MODE

Dynamic programming and recursion

TODO Recursive String Permutations

TODO Compute nth Fibonacci Number

TODO Making Change

TODO The Cake Thief

DONE Balanced Binary Tree

DONE Binary Search Tree Checker

DONE 2nd Largest Item in a Binary Search Tree

Queues and stacks

TODO Largest Stack

TODO Implement A Queue With Two Stacks

TODO Parenthesis Matching

TODO Bracket Validator

Linked lists

DONE Delete Node

TODO Does This Linked List Have A Cycle?

TODO Reverse A Linked List

TODO Kth to Last Node in a Singly-Linked List

TODO Find Repeat, Space Edition BEAST MODE

System design

TODO URL Shortener

TODO MillionGazillion

TODO Find Duplicate Files

General programming

TODO Rectangular Love

TODO Temperature Tracker

Bit manipulation

TODO Binary Numbers

TODO The Stolen Breakfast Drone

Combinatorics, probability, and other math

TODO Which Appears Twice

TODO Find in Ordered Set

DONE In-Place Shuffle

TODO Simulate 5-sided die

TODO Simulate 7-sided die

TODO Two Egg Problem

JavaScript

TODO JavaScript Scope

TODO What's Wrong with This JavaScript?

Coding interview tips

TODO How The Coding Interview Works

TODO General Coding Interview Advice

TODO Impostor Syndrome

TODO Why You Hit Dead Ends

TODO Tips for Getting Unstuck

TODO The 24 Hours Before Your Interview

TODO Beating Behavioral Questions

TODO Managing Your Interview Timeline