摘要: 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 must be in-place, do not allocate extra memory. Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column. 阅读全文
posted @ 2013-12-15 13:58 般若一号 阅读(250) 评论(0) 推荐(0) 编辑
摘要: Substring with Concatenation of All Words 阅读全文
posted @ 2013-12-10 00:28 般若一号 阅读(328) 评论(0) 推荐(0) 编辑
摘要: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. Note: You may not slant the container. 阅读全文
posted @ 2013-10-28 13:03 般若一号 阅读(504) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not. 阅读全文
posted @ 2013-10-24 16:57 般若一号 阅读(272) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, remove the nth node from the end of list and return its head. 阅读全文
posted @ 2013-10-24 12:45 般若一号 阅读(217) 评论(0) 推荐(0) 编辑
摘要: Given a digit string, return all possible letter combinations that the number could represent. 阅读全文
posted @ 2013-10-24 01:40 般若一号 阅读(378) 评论(0) 推荐(0) 编辑
摘要: 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. 阅读全文
posted @ 2013-10-20 00:26 般若一号 阅读(1341) 评论(0) 推荐(0) 编辑
摘要: 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. 阅读全文
posted @ 2013-10-20 00:01 般若一号 阅读(445) 评论(0) 推荐(0) 编辑
摘要: 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. 阅读全文
posted @ 2013-10-19 21:19 般若一号 阅读(828) 评论(0) 推荐(0) 编辑
摘要: Write a function to find the longest common prefix string amongst an array of strings. 阅读全文
posted @ 2013-10-14 23:13 般若一号 阅读(693) 评论(0) 推荐(0) 编辑