摘要:
Given an array *nums* containing *n* + 1 integers where each integer is between 1 and *n* (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. 阅读全文
摘要:
Given a positive integer *n*, find the least number of perfect square numbers (for example, `1, 4, 9, 16, ...`) which sum to *n*. 阅读全文
摘要:
Given a string containing just the characters `'('` and `')'`, find the length of the longest valid (well-formed) parentheses substring. 阅读全文
摘要:
Merge *k* sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 阅读全文
摘要:
There are two sorted arrays **nums1** and **nums2** of size m and n respectively.
Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 阅读全文
摘要:
You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols `+` and `-`. For each integer, you should choose one from `+` and `-` as its new symbol. 阅读全文
摘要:
Given a **non-empty** array containing **only positive integers**, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. 阅读全文
摘要:
Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers `(h, k)`, where `h` is the height of the person and `k` is the number of people in front of this person who have a height greater than or equal to `h`. Write an algorithm to reconstruct the queue. 阅读全文
摘要:
Given an encoded string, return it's decoded string. 阅读全文
摘要:
Given a non-empty array of integers, return the **k** most frequent elements. 阅读全文