Skip to content

Instantly share code, notes, and snippets.

View frankstepanski's full-sized avatar
🏠
Working from home

Frank Stepanski frankstepanski

🏠
Working from home
View GitHub Profile
@frankstepanski
frankstepanski / node-lts.txt
Last active March 5, 2024 21:12
Install latest version of node (Long Term Support)
nvm install --lts
@frankstepanski
frankstepanski / algorithm-template.js
Last active April 11, 2022 00:43
Data Structure and Algorithm Coding Template
/**
* Interivew Tips:
*
* - Write examples and clarify the question
* - Ask questions that unearth the actual problem the interviewer wants you to solve.
* - Come up with solutions and explain them to the interviewer.
* - Once the interviewer seems to settle on one, write down simple steps, not more than a few lines.
* - Doing this makes it clear (to both of you) what you will code for the rest of the interview.
* - Write down test cases, when an interviewer sees you do this, they know you are legit.
* - Make liberal use of helper functions.
@frankstepanski
frankstepanski / Linked-Lists-Merge.md
Last active March 20, 2022 21:57
Interview Prep Algo - Linked Lists - Merge Two Linked Lists

Merge Two Linked Lists

Learning Objective

  • Apply pointer logic to multiple linked lists

Interviewer Prompt

Write a function that takes in the heads of two Singly Linked Lists that are in sorted order, respectively. The function should merge the lists in place (i.e., it shouldn't create a brand new list) and return the head of the merged list; the merged list should be in sorted order.

Each LinkedList node has an integer value as well as a next node pointing to the next node in the list or to null if it's the tail of the list.

@frankstepanski
frankstepanski / stacks-queues-linked-lists.md
Last active January 2, 2022 22:29
Interview Prep Algo - Stacks, Queues & Linked Lists

Stacks, Queues, & Linked Lists

The main purpose of this lecture is to identify moments in problems that will lead us to decide on these data types/data structures as useful approaches in interviewing problems.

When do we use stacks?

  • Direct implementation questions (i.e. build a stack with 2 queues)
  • Depth-first search/traversal (DFS) of trees/matrices/graphs
    • a subset of backtracking
  • Iterative implementation of recursive algorithms (i.e. instead of a callstack, using an actual stack in the function)
  • Indirect implementations
@frankstepanski
frankstepanski / Pair-Sum.md
Created January 2, 2022 22:21
Interview Prep Algo - Pair Sum

Pair Sum

Learning Objective

  • Apply Pointers to reduce time complexity

Interviewer Prompt

Given an array arr consisting of N integers, sorted in ascending order (least to greatest), and a separate number (a sum), determine if any 2 numbers in the array add up to the sum. Return true if any 2 different numbers within the array add up to sum. Return false if no 2 numbers in the array add up to sum.

@frankstepanski
frankstepanski / String-Search.md
Last active January 2, 2022 22:19
Interview Prep Algo - String Search

String Search

Prompt

You are attempting to find the index of the first appearance of one string (the needle) inside of another (the haystack).


Examples

@frankstepanski
frankstepanski / Palindrome-Check.md
Last active January 2, 2022 22:20
Interview Prep Algo - Palindrome Check

Palindrome Check

Interviewer Prompt

Given an string str, create a function that returns a boolean, corresponding to whether that string is a palindrome (spelled the same backwards and forwards). Our palindrome check should be case-insensitive.

Examples

isPal('car') => false
isPal('racecar') => true
@frankstepanski
frankstepanski / big-0.md
Last active August 31, 2021 22:27
The idea behind big O notation

Big O notation is for talking about how long an algorithm takes to run

It's how we compare the efficiency of different approaches to a problem.

With big O notation we express the runtime in terms of how quickly it grows relative to the input, as the input gets large.

  1. how quickly the runtime grows—It's hard to pin down the exact runtime of an algorithm. It depends on the speed of the processor, what else the computer is running, etc. So instead of talking about the runtime directly, we use big O notation to talk about how quickly the runtime grows.

  2. relative to the input—If we were measuring our runtime directly, we could express our speed in seconds. Since we're measuring how quickly our runtime grows, we use the size of the input, which we call "n." So we can say things like the runtime grows "on the order of the size of the input" (O(n) or "on the order of the square of the size of the input" (O(n2).

@frankstepanski
frankstepanski / event-listeners.md
Last active July 13, 2021 02:42
Describing difference between event.target and event.currentTarget

Event listeners

When you create an event handler, you need to associate it with an element in the DOM. For example, the user may click a button. You then register an event handler on the button to run when the button's click event fires.

The mechanism that detects the event is called an event listener. An event listener contains an event name and an event handler. When the event fires, the event handler is executed.

const firstBtn = document.querySelector("button");
@frankstepanski
frankstepanski / mongoDB.md
Last active June 12, 2021 00:12
MongoDB and Mongoose

MongoDB and Mongoose

MongoDB is the most popular non-relational database in use today. It is a document-oriented database that can store data in the form of documents, which are similar to objects in javascript. Instead of tables in SQL, we have collections. Instead of columns in SQL, we have keys. Instead of rows in SQL, we have documents.

NoSQL databases like MongoDB are inherently more flexible than SQL databases as they do not need to follow a model. While a SQL table can only contain rows that conform to the specific schema of columns, collections in a NoSQL database