Invert Binary Tree

Invert a binary tree so that the left and right children of each node swap.

Valid Palindrome

A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.

Lowest Common Ancestor

Given the root and two nodes in a binary tree. Find the lowest common ancestor(LCA) of the two nodes.

Valid Sudoku

Given a Sudoku board, write an algorithm to determine if the board is valid.

Insert Node in a Binary Search Tree

Given a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a valid binary search tree.

Ugly Number II

Ugly number is a number that only have factors 2, 3 and 5. Design an algorithm to find the nth ugly number. The first 10 ugly numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, ...

Binary Search Tree Iterator

Design an iterator over a binary search tree with the following rules:

Cosine Similarity

Cosine similarity is a measure of similarity between two vectors of an inner product space that measures the cosine of the angle between them. The cosine of 0° is 1, and it is less than 1 for any other angle. It is defined as follows:

Longest Common Prefix

Given k strings, find the longest common prefix (LCP).

First Bad Version

The code base version is an integer start from 1 to n. One day, someone committed a bad version in the code case, so it caused this version and the following versions are all failed in the unit tests. Find the first bad version.