Skip to content

Instantly share code, notes, and snippets.

View iamannamai's full-sized avatar

Anna Mai iamannamai

View GitHub Profile

Slides


Prompt

You're an industrious programmer that lives off the grid. The local well that you use to fetch water has gone dry, so you've decided to collect rain water to filter; however, your collection device isn't flat.

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water your collection device is able to trap after raining.

class: center middle

Reverse a Linked List


Interviewer Prompt

const mkNode = (value, next = null) => ({ value, next })
const nums = mkNode(1, mkNode(2, mkNode(3)))

OOP Design

OOP Design is a good exercise on how to split up our system into different objects/classes. The main difficulty with problems like these are that they are open-ended and force you to think abstractly and creatively. One of the other main goals of this exercise is to be able to draw out diagrams to help with communicating abstract ideas before they are implemented in code. These problems are language agnostic.


Design an ATM

PROMPT: Using object oriented programming principles, class diagrams and activity diagrams, design an ATM.

We are being explicit here, however, you might not get this luxury from an interviewer as they might just ask, "Using object oriented design, design an ATM".

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
subsetSum(9, [1, 10, 5, 3]); // true

Multiplicative Persistence


Interviewer Prompt

Given a non-negative integer, write a function that returns its multiplicative persistence--the number of times you must multiply the digits in a number together until you reach a single digit product.

Ex: 39 returns 3

Unique Paths


Interviewer Prompt

You are given the dimensions of a grid, m and n. Starting from the top left, or (0,0), you want to end up making your way to the bottom right corner. The only two moves you can make are to go one space directly to your right, or one space directly down. Write a function that can help you determine how many unique paths you can take between these two corners.


Two Number Sum


Interviewer Prompt

Given an array of numbers and a target 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.

@iamannamai
iamannamai / 3.4_queues_via_stacks.md
Last active June 25, 2019 21:18
REACTO - Queues via Stacks

Queues via Stacks


Question

Implement a MyQueue class which implements a queue using two stacks.


Hints