Skip to content

Instantly share code, notes, and snippets.

Slides


Prompt

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

You are given an input string consisting of brackets—square [ ], round ( ), and curly { }. The input string can include other text. Write a function that returns either true if the brackets in the input string are balanced or false if they are not. Balanced means that any opening bracket of a particular type must also have a closing bracket of the same type.

@cchoi34
cchoi34 / riverSizes.md
Created December 9, 2019 21:53 — 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.

For example:

const input = [