摘要: http://oj.leetcode.com/problems/next-permutation/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 阅读全文
posted @ 2013-10-30 21:34 移山测试工作室黑灯老师 阅读(527) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/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.F 阅读全文
posted @ 2013-10-30 17:53 移山测试工作室黑灯老师 阅读(6523) 评论(2) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/divide-two-integers/Divide two integers without using multiplication, division and mod operator.思路:典型的二分法。以87除4举例, (4 * 2 = 8) => (8 * 2 = 16) => (16 * 2 = 32) => (32 * 2) => 64,因为64 * 2 = 128大于87,现在我们可以确定4 * 16 = 64小于87,那么再处理87 - 64 = 23,23除4的话用上面方法可以得到5, 阅读全文
posted @ 2013-10-30 16:18 移山测试工作室黑灯老师 阅读(2313) 评论(1) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/implement-strstr/Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.思路:太简单了,没什么好说的。 1 class Solution { 2 public: 3 char *strStr(char *haystack, char *needle) { 4 int len_haystack = strlen(haystack), l... 阅读全文
posted @ 2013-10-30 15:11 移山测试工作室黑灯老师 阅读(560) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/remove-element/Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.思路:和Remove Duplicates from Sorted Array类似,当已经删除n个元素后,需要保留的 阅读全文
posted @ 2013-10-30 14:14 移山测试工作室黑灯老师 阅读(540) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.For example,Given i 阅读全文
posted @ 2013-10-30 14:03 移山测试工作室黑灯老师 阅读(436) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/reverse-nodes-in-k-group/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 阅读全文
posted @ 2013-10-30 13:39 移山测试工作室黑灯老师 阅读(420) 评论(0) 推荐(0) 编辑
count website visits
Buy Computers