上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 19 下一页
摘要: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially filled sudoku which... 阅读全文
posted @ 2017-02-06 14:42 copperface 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.分析不能用除法,所以使用减法不断减 除数,同时对 除数 倍乘,进行加速除数:3 -> 6 -> 12 ...边界条件:1 除数为0,溢出2 被除数 INT_MIN,同时除数 -1,... 阅读全文
posted @ 2017-02-04 17:18 copperface 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which ha... 阅读全文
posted @ 2017-02-04 17:17 copperface 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers sorted in ascending order, 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 i... 阅读全文
posted @ 2017-02-04 17:16 copperface 阅读(154) 评论(0) 推荐(0) 编辑
摘要: Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the a... 阅读全文
posted @ 2017-02-04 11:14 copperface 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 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 ord... 阅读全文
posted @ 2017-01-24 15:51 copperface 阅读(188) 评论(0) 推荐(0) 编辑
摘要: You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and wi... 阅读全文
posted @ 2017-01-24 12:42 copperface 阅读(238) 评论(0) 推荐(0) 编辑
摘要: KMP背景分析普通算法(遍历),会遗忘所有之前比较过的信息,导致每一次移位,都要重新重头比较每一个字符。这将会导致 O(mn)的时间复杂度(m: 关键字符长度,n: 文本string的长度)而KMP算法,则能够保证不去重复比较已经部分匹配的字符,比如序列“abcdabac”,如果“abcd”部分匹配了文本,而在接下来的“a”位置上不匹配,那么算法则会直接跳过4个位置,重新进行比较,而不是移位1个,... 阅读全文
posted @ 2017-01-18 09:43 copperface 阅读(643) 评论(0) 推荐(0) 编辑
摘要: Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.分析这就是字符串匹配算法算法一:brute forcetime complexity: O(nm)space complexity: O(1)12345... 阅读全文
posted @ 2017-01-17 22:27 copperface 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may not... 阅读全文
posted @ 2017-01-13 14:04 copperface 阅读(144) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 19 下一页