Skip to content

Instantly share code, notes, and snippets.

View haase1020's full-sized avatar
Coding with joy!

Mandi Haase haase1020

Coding with joy!
View GitHub Profile
@haase1020
haase1020 / mandihaase-resume.md
Last active September 8, 2020 18:43
Mandi Haase Resume

Mandi Haase

mandihaase@gmail.com
(910)354-9330
Alexandria, VA
GitHub | LinkedIn

About Me

I am a full-stack developer by day and educator/ Japanese translator by night. I love creating software, learning, and working with agile teams. I am passionate about getting to the heart of the matter, improving efficiency and productivity, and pretty much everything tech-related. I have vast experience in education and translation, a background in finance, and believe the sky's the limit in what you can achieve if you put your mind to it. In my spare time, you can find me with a good book or power walking.

@haase1020
haase1020 / convertSortedArrayToBinarySearchTree.js
Created November 27, 2021 08:53
recursive solution to leet code problem #108 convert a sorted array into a binary search tree
//Definition for a binary tree node; needs to be called with "new"
function TreeNode(val) {
this.val = val;
this.right = null;
this.left = null;
}
var sortedArrayToBST = function(nums) {
// base cases
@haase1020
haase1020 / symmetricTreeIterative.js
Last active December 4, 2021 10:57
#101 LeetCode Symmetric Tree Iterative Javascript Solution
var isSymmetric = function (root) {
if (!root) {
return "no tree was provided 🤔"; // return true
}
if (!root.left && !root.right) {
return "you have a symmetric tree that only has 1 node...the root 🌱!"; // return true
}
let queue = [];
queue.unshift(root);
queue.unshift(root);
@haase1020
haase1020 / symmetricTreeRecursive.js
Last active December 4, 2021 10:49
#101 LeetCode Symmetric Tree Recursive Solution
var isSymmetric = function (root) {
if (!root) return "no tree was provided 🤔"; // return true
return dfs(root.left, root.right);
function dfs(leftNode, rightNode) {
console.log("running this code block"); // this will run at most for the total number of nodes in the tree
if (!leftNode && !rightNode) {
return "you have a perfectly symmetric tree! 🌲"; //return true
}
if (
@haase1020
haase1020 / cleanHouse.js
Last active December 6, 2021 08:06
clean house recursive function
const todoList = [
"pick up the floor",
"clear the table",
"put away dishes",
"sweep",
"clean the bathrooms",
"dust",
"mop",
];
@haase1020
haase1020 / cleanHouseOptimized
Last active December 6, 2021 08:08
clean house recursive optimized
const todoList = [
"pick up the floor",
"clear the table",
"put away dishes",
"sweep",
"clean the bathrooms",
"dust",
"mop",
];
@haase1020
haase1020 / factorialRecursive.js
Last active December 6, 2021 09:47
factorial recursive
function factorial(n) {
if (n == 0 || n == 1) {
return 1;
} else {
console.log("running"); // should run 5 times
return n * factorial(n - 1);
}
}
console.log(factorial(5)); //5*4*3*2*1 = 120
@haase1020
haase1020 / factorialIterative.js
Created December 6, 2021 09:46
factorial iterative
function factorial(n) {
let answer = 1;
if (n == 0 || n == 1) {
return answer;
} else {
for (var i = n; i >= 1; i--) {
console.log("running"); // should log 5 times
answer = answer * i;
}
return answer;
@haase1020
haase1020 / fibonacciRecursive
Created December 6, 2021 09:51
fibonacci recursive
// multiple recursion: one than one recursive call per iteration
// time complexity: O(2^n) or exponential time
// space complexity: O(n)
function fibonacci(n) {
if ((n === 1) | (n === 2)) return 1;
return fibonacci(n - 1) + fibonacci(n - 2); // multiple calls of fibonacci
}
// better but still slower than iterative
function fibonacciMemoized(n, cache = []) {
@haase1020
haase1020 / binaryTreeInorderTraversal.js
Created December 6, 2021 10:32
binary tree inorder traversal
// https://leetcode.com/problems/binary-tree-inorder-traversal/
const dft = (root, result) => {
if (!root) return;
dft(root.left, result);
result.push(root.val);
dft(root.right, result);
return result;
};