Skip to content

Instantly share code, notes, and snippets.

View kyvycodes's full-sized avatar

Kay H. kyvycodes

  • New York, New York
View GitHub Profile

Rain Water Collector 🌧⛈


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 fill it; 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 occurs.

Design a Public Transit Tracker 🛤🚂

Back story

OOP Design (object-oriented programming) is a good exercise to show how to split up our system into different components. You can think of React Components but instead, we are separating our system into different objects/classes. The important factor of this problem and problems like these are that they are opened ended and force you to think abstractly and creatively. The main goal of this exercise is to be able to draw out diagrams to communicate abstract ideas before they begin to be implemented with code.

These problems are language agnostic (meaning language-neutral, or cross-language)

Learning Objective

  • To understand and design activity diagrams and class diagrams.

Balanced Brackets

Learning Objective

  • Understand use cases for stacks

Interviewer Prompt

Write a function that determines whether an input string has balanced brackets.

Reverse a Linked List ⛓⛓


Learning Objective

  • Implement multiple pointers with linked lists
  • Implement recursion with linked lists
  • White Board Practice / Technical Communication

Interviewer Prompt

Merge Two 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.

Examples

Bubble Sort 🛁


Interviewer Prompt

Write a function that takes in an array of integers and returns a sorted version of that array. Use the Bubble sort algorithm to sort the array.


Setup and Examples

Binary Search 🕵🕵️‍♂️


Interviewer Prompt

Write a function that takes in a sorted array of integers as well as a target value. The function should use the Binary Search Algorithm to determine if the target value is contained in the array and should return its index if it is, otherwise it should return -1.


Setup and Examples

Tree Traversal 🌳


Interviewer Prompt

Given a binary tree, write a function that will return the node in the tree with greatest depth. You may assume there is a unique deepest node.


Setup and Example

River Sizes

Interviewer Prompt

You are given a two-dimensional array (a matrix) of potentially unequal height and width that contains only values of 0 and 1. Each 0 represents land, and each 1 represents part of a river. A river consists of any number of 1s that are either horizontally or vertically adjacent, but not diagonally adjacent. The number of adjacent 1s forming a river determine it's size.

Write a function that returns an array of the sizes of all rivers represented in the input matrix. The sizes do not need to be in any particular order.

Example

const matrix = [
@kyvycodes
kyvycodes / array-three-sum.md
Last active December 14, 2022 14:12
REACTO

Array Three Sum

Interviewer Prompt

Given an array of distinct integers (non repeating) and an integer representing a target sum, write a function that returns an array of all triplets in the input array that sum up to the target sum.

  • if no three numbers sum up to the target sum, the function should return an empty array.

Examples