- 浏览: 91863 次
- 性别:
- 来自: 南京
最新评论
文章列表
Search for a RangeMar 3 '125093 / 13502
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target is not found in the array, return
Substring with Concatenation of All WordsFeb 24 '125071 / 18608
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters.
For ...
Next PermutationFeb 25 '124235 / 11932
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
The replacement m ...
Reverse Nodes in k-GroupFeb 16 '123953 / 13303
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
You may not alter the values in the nodes, onl ...
Letter Combinations of a Phone NumberJan 27 '124852 / 14644
Given a digit string, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below.
3SumJan 18 '128685 / 33750
Given an array S of n integers, are there elements a, b, c in
Palindrome NumberJan 4 '126687 / 16659
Determine whether an integer is a palindrome. Do this without extra space.
重来没有这么爽过!
class Solution {
public:
int reverse(int x) {
int r = 0;
while (x > 0) {
r = 10 * r + x % 10;
x /= 10;
...
String to Integer (atoi)Dec 27 '116739 / 30948
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.
Reverse IntegerDec 26 '116571 / 11753
Reverse digits of an integer.
Example1: x = 123, return 321Example2: x = -123, return -321
Have you thought about this?
Here are some good questions to ask before coding. Bonus points for you if you have already thought through this!
If the integer's la ...
Longest Palindromic SubstringNov 11 '116971 / 22796
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.
» So
Median of Two Sorted ArraysMar 28 '116215 / 31527
There are two sorted arrays A and B 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)).
» Solve this problem
很久前就见过这题,当时随便一想,以为自己想到了logN的方法。
前几天又看到,打算写一下。发现之前的想法不靠谱啊! ...
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.
Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3].
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.
For example, given s = "aab",Return 1 since the palindrome partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "aab",Return
[
["aa","b"],
["a","a","b"]
]
dp[i][j]=1表示s ...
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.
...