Skip to content

Instantly share code, notes, and snippets.

View kellyegoodman's full-sized avatar

Kelly Goodman kellyegoodman

  • Austin, TX
View GitHub Profile
@kellyegoodman
kellyegoodman / gridTraveler.cpp
Last active March 31, 2022 00:35
Dynamic Programming - Memoization Example using the GridTraveler problem
#include <iostream>
#include <unordered_map>
#include <vector>
/* --------------------------------------------------------------------------------------- */
/* GridTraveler Problem
You are a traveler on a 2D grid. You begin in the top-left corner and your goal
is to travel to the bottom-right corner. You may only move down or right.
In how many ways can you travel to the goal on a grid with dimension m X n?
Write a function gridTraveler(m,n) that calculates this.
@kellyegoodman
kellyegoodman / fibonacci.cpp
Created December 15, 2021 01:51
Dynamic Programming - Memoization Example using Fibonacci Sequence
#include <iostream>
#include <unordered_map>
/* --------------------------------------------------------------------------------------- */
/* Fibonacci
This code compares the runtime complexities of a memoized Fibonacci sequence calculation
and a non-memoized Fibonacci sequence calculation.
Commands to compile and run (on Windows):
> g++ fibonacci.cpp -o fib
@kellyegoodman
kellyegoodman / fizzbuzz.cpp
Last active August 10, 2021 16:04
C++ Fizzbuzz Implementation
#include <iostream>
#include <map>
#include <string>
/* FizzBuzz prints numbers 1 through n but replaces numbers which are multiples of 3 with "Fizz",
* numbers which are multiples of 5 with "Buzz", and numbers which are multiples of both with "FizzBuzz"
*/
void FizzBuzz(int n)
{
// Map of integers to replacement strings for executing FizzBuzz