### 描述

Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?

For example,
Given n = 3, there are a total of 5 unique BST’s.

### 描述

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

Assume a BST is defined as follows:

• The left subtree of a node contains only nodes with keys less than the node’s key.
• The right subtree of a node contains only nodes with keys greater than the node’s key.
• Both the left and right subtrees must also be binary search trees.

### 描述

Two elements of a binary search tree (BST) are swapped by mistake.

Recover the tree without changing its structure.

Note:
A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?

### 描述

The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id.

The Department table holds all departments of the company.

Write a SQL query to find employees who have the highest salary in each of the departments. For the above tables, Max has the highest salary in the IT department and Henry has the highest salary in the Sales department.

TODO

### 描述

• 1 <= arr.length <= 10^5
• -100 <= arr[i] <= 100

### 描述

Write a SQL query to get the second highest salary from the Employee table.

For example, given the above Employee table, the second highest salary is 200. If there is no second highest salary, then the query should return null.

### 描述

Table: Person

Table: Address

Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people:

### 描述

Write a SQL query to find all numbers that appear at least three times consecutively.

For example, given the above Logs table, 1 is the only number that appears consecutively for at least three times.

### 描述

Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.

Table: Customers.

Table: Orders.

Using the above tables as example, return the following:

### 描述

Write a SQL query to find all duplicate emails in a table named Person.

For example, your query should return the following for the above table: