Skip to main content

22 docs tagged with "hash-table"

View all tags

Binary Tree Column Order Traversal

Given a binary tree, return its column order traversal from top to bottom and left to right. Note: if two nodes are in the same row and column, order them from left to right.

Can Construct Passage

This question is asked by Amazon. Given two strings, passage and text, return whether or not the characters in text can be used to form the given passage.

Contains Duplicate II

This question is asked by Google. Given an array, nums, and an integer k, return whether or not two unique indices exist such that nums[i] = nums[j] and the two indices i and j are at most k elements apart.

Count Partners

Given an integer array nums, return the total number of "partners" in the array.

Find All Duplicates in Array

Given an array of integers nums, each element in the array either appears once or twice. Return a list containing all the numbers that appear twice.

Frog Jump

A frog is attempting to cross a river to reach the other side. Within the river, there are stones located at different positions given by a stones array (this array is in sorted order). Starting on the first stone (i.e. stones[0]), the frog makes a jump of size one potentially landing on the next stone. If the frog's last jump was of size x, the frog's next jump may be of size x - 1, x, or x + 1. Given these following conditions return whether or not the frog can reach the other side.

Happy Number (Magical Number)

Given an integer n, return whether or not it is a "magical" number. A magical number is an integer such that when you repeatedly replace the number with the sum of the squares of its digits, it eventually becomes one.

Keyboard Row

Given a list of words, return all the words that require only a single row of a keyboard to type.

Kill Process

You are given two lists of integers and an integer representing a process id to kill. One of the lists represents a list of process ids and the other represents a list of each of the processes' corresponding (by index) parent ids. When a process is killed, all of its children should also be killed. Return a list of all the process ids that are killed as a result of killing the requested process.

Majority Element

High school students are voting for their class president and you're tasked with counting the votes. Each presidential candidate is represented by a unique integer and the candidate that should win the election is the candidate that has received more than half the votes. Given a list of integers, return the candidate that should become the class president.

Partition Labels

Given a string s containing only lowercase characters, return a list of integers representing the size of each substring you can create such that each character in s only appears in one substring.

Path Sum III

Given the reference to the root of a binary tree and a value k, return the number of paths in the tree such that the sum of the nodes along the path equals k.

Reorganize String

This question is asked by Facebook. Given a string, check if it can be modified such that no two adjacent characters are the same. If it is possible, return any string that satisfies this condition and if it is not possible return an empty string.

Two Sum

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

Two Sum IV - Input is a BST

Given the reference to the root of a binary search tree and a target value, return whether or not two individual values within the tree can sum to the target.

Word Break

This question is asked by Amazon. Given a string s and a list of words representing a dictionary, return whether or not the entirety of s can be segmented into dictionary words.

Word Pattern

Given a string s and a string code, return whether or not s could have been encrypted using the pattern represented in code.