Flatten Nested List Iterator

Given a nested list of integers, implement an iterator to flatten it.

Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative.

Set Matrix Zeroes

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.

Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list.


The size of the hash table is not determinate at the very beginning. If the total size of keys is too large (e.g. size >= capacity / 10), we should double the size of the hash table and rehash every keys. Say you have a hash table looks like below:

Longest Common Substring

Given two strings, return the length of the longest common substring.

Binary Tree Maximum Path Sum

Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree.

Swap Two Nodes in Linked List

Given a linked list and two values v1 and v2. Swap the two nodes in the linked list with values v1 and v2. It’s guaranteed there is no duplicate values in the linked list. If v1 or v2 does not exist in the given linked list, do nothing.

Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list.

Decode Ways

A message containing letters from A to Z is being encoded to numbers using the following mapping: