Skip to content

Instantly share code, notes, and snippets.

View nmestrada's full-sized avatar
:octocat:

Natalie Estrada nmestrada

:octocat:
View GitHub Profile
@nmestrada
nmestrada / README-Template.md
Created October 29, 2019 19:02 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@nmestrada
nmestrada / riverSizes.md
Last active April 9, 2020 13:32 — forked from krnsk0/riverSizes.md
River Sizes Prompt & Solution

River Sizes

Prompt

You are given a two-dimensional array of potentially unequal height and width. It contains only 0s and 1s. This array represents a map: 0s are land, and 1s are water. A "river" on this map consists of any number of contiguous, adjacent water squares, where "adjacent" means "above", "below", "to the left of", or "to the right of" (that is, diagonal squares are not adjacent). Write a function which returns an array of the sizes of all rivers represented in the input matrix. Note that these sizes do not need to be in any particular order.

It's sorta similar to the flood fill algorithm! Remember the good 'ol paint fill?

For example:

@nmestrada
nmestrada / riverSizesPrompt.md
Created December 10, 2019 03:07
riverSizesPrompt

River Sizes

Prompt

You are given a two-dimensional array of potentially unequal height and width. It contains only 0s and 1s. This array represents a map: 0s are land, and 1s are water. A "river" on this map consists of any number of contiguous, adjacent water squares, where "adjacent" means "above", "below", "to the left of", or "to the right of" (that is, diagonal squares are not adjacent). Write a function which returns an array of the sizes of all rivers represented in the input matrix. Note that these sizes do not need to be in any particular order.

For example:

const input = [

Substring Search

Prompt

Write a function, indexOf, which takes in two strings--the needle and the haystack--and returns the index of the first appearance of the needle in the haystack. If the needle does not appear in the haystack, return -1. Don't use indexOf(), includes() or substring(),

indexOf('or', 'hello world'); // should return 7
indexOf('hello world', 'or'); // should return -1
indexOf('howdy', 'hello world'); // should return -1

Intersection


Prompt

Given two sorted arrays of numbers, return an array containing all values that appear in both arrays. The numbers in the resulting array (the "intersection") may be returned in any order, they needn't be sorted.

You can assume that each array has only unique values (no duplicates within the array).

@nmestrada
nmestrada / graphPathChecker.md
Created February 23, 2020 21:40
interviewer && interviewee gist

Graph Path Checker

Prompt

Write a function that determines if a path exists between two vertices of a directed graph.

Recall that a graph is a collection of connections, or 'edges', linking together nodes or verticies. In a directed graph, each edge is like an arrow or a one-way street-- an edge linking A to B indicates that A connects to B, but not that B connects to A.

The graph passed to the function will be represented as an object with a structure sometimes called an 'adjacency list' or 'adjacency map', in which each key represents a node in the graph, and each value will consist in an array of nodes which can be reached from the key. For example, the following object:

Prompt

Given a staircase with a given number of stairs, num, write a function that returns the number of different ways one can climb this set of stairs. A person is able to climb the stairs either one at a time, or skip a step, or a mix of both.

Examples

climbStairs(2); // should return 2: one step at a time (1 + 1), or skip a step (2).
climbStairs(0); // should return 1
climbStairs(1); // should return 1
climbStairs(5); // should return 8
climbStairs(100); // should return 573147844013817200640
@nmestrada
nmestrada / subset-sum.md
Created February 23, 2020 21:41 — forked from garrett-green/subset-sum.md
Subset Sum

Prompt

Given a target sum and an array of positive integers, return true if any combination of numbers in the array can add to the target. Each number in the array may only be used once. Return false if the numbers cannot be used to add to the target sum.

Examples

subsetSum(2, [1, 10, 5, 3]); // false
subsetSum(10, [1, 10, 5, 3]); // true (10 === 10)
subsetSum(9, [1, 10, 5, 3]); // true (1+3+5 === 9)
@nmestrada
nmestrada / anagram_detector_interviewers.md
Created February 23, 2020 21:41 — forked from benpjenkins/anagram_detector_interviewers.md
Anagram detector - for interviewers only!

Prompt

You are given an array of strings only (could be words, phrases etc). Create a function to find all the anagrams within that array. The output should be an array where each element in the array is itself an array of anagrams.


Examples

const words = ['cat', 'act', 'ignore', 'a phrase', 'tape', 'pate', 'e hpsara', 'tac'];
@nmestrada
nmestrada / OneAway.md
Created February 23, 2020 21:41 — forked from cchoi34/OneAway.md

One Away

Prompt

There are three types of edits that can be made to a string:

  • Replace: Replacing a single character with another character on the string
  • Insert: Inserting a single character into a string, making it 1 length longer
  • Removal: Deleting a single character from a string, making it 1 length shorter

Write a function that takes in two strings, and returns true if the two strings are one "edit" or zero "edits" away from each other (false if not).