Skip to content

Instantly share code, notes, and snippets.

Partition Labels


Prompt

A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of intergers representing the size of these parts.


Prompt

Given an an array of numbers, return the length of the longest possible subsequence that is increasing. This subsequence can "jump" over numbers in the array. For example in [3, 10, 4, 5] the longest increasing subsequence (LIS) is [3, 4, 5] so it would return 3.

Examples

longestIncreasingSubsequence([3, 4, 2, 1, 10, 6]);
// should return 3, the length of the longest increasing subsequence:
// 3, 4, 6 (or 3, 4, 10)

class: center middle

Solving Graphs


Interviewer Prompt

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

The graph will be represented as an object, each of whose keys represents a vertex of the graph and whose value represents all vertices that can be reached from the aforementioned key.

Dictionary Word Finder


Interviewer Prompt

Given an alphabetical array of dictionary entries and a word to search for, find that word's definition (if it exists). A dictionary entry is just a string where the word's name appears first, followed by - [definition].

const dictionary = [
  'a - Used when mentioning someone or something for the first time in a text or conversation',

OOP Design

OOP design requires you to think about real world items or systems technically, and organize your interpretations into classes that hold data and methods. These problems are meant to give insight into your coding style and mindset and how you approach a real world problem technically.

Prompt (Cracking the Code Interview, Q: p.127 | S: p.305)

Deck of Cards: Design the data structures for a generic deck of cards. Explain how you would subclass the data structures to implement blackjack.

General Steps for solving OOP Design (as told by Cracking The Coding Interview)