## 3Sum Closest

Given an array `S`

of `n`

integers, find three integers in `S`

such that the sum is closest to a given number, `target`

. Return the sum of the three integers. You may assume that each input would have exactly one solution.

## 4Sum

Given an array `S`

of `n`

integers, are there elements `a`

, `b`

, `c`

, and `d`

in `S`

such that `a + b + c + d = target`

? Find all unique quadruplets in the array which gives the sum of target. Elements in a quadruplet `(a, b, c, d)`

must be in non-descending order. (ie, `a ≤ b ≤ c ≤ d`

) The solution set must not contain duplicate quadruplets.

## 3Sum

Given an array `S`

of `n`

integers, are there elements `a`

, `b`

, `c`

in `S`

such that `a + b + c = 0`

? Find all unique triplets in the array which gives the sum of zero. Elements in a triplet `(a, b ,c)`

must be in non-descending order. (ie, `a ≤ b ≤ c`

)

## Two Sum

Given an array of integers, find two indices in the array where the values sum to a target. The first index must be less than the second index, and the indicies starts with 1, not 0.

## Binary Tree Serialization

Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called ‘serialization’ and reading back from the file to reconstruct the exact same binary tree is ‘deserialization’. Trees are represented in breadth-first order. See Binary Tree Representation for details.

## Min Stack

Implement a stack with `min()`

function, which will return the smallest number in the stack. The min-stack supports three operations: `push()`

, `pop()`

, and `min()`

. The `push()`

and `pop()`

are normal stack operations, and the `min()`

operation should return the minimum value on the stack without removing an item from the stack. All three operations should have O(1) time-complexity.

## Kth Largest Element

Find K-th largest element in an array.

## Digit Counts

Count the number of occurrences of a digit, `k`

, in numbers between `0`

to `n`

, inclusively. The digit `k`

can be `0`

to `9`

.

## Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST).

## Reverse Pairs

For an array `A`

, if `i < j`

, and `A [i] > A [j]`

, then `(A [i], A [j])`

is a reversed pair. Find the total number of reversed pairs in `A`

.