This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |