09 2014 档案

Remove Nth Node From End of List
摘要:Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After rem 阅读全文

posted @ 2014-09-16 09:43 bug睡的略爽 阅读(175) 评论(0) 推荐(0)

Letter Combinations of a Phone Number
摘要:Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telepho 阅读全文

posted @ 2014-09-15 22:55 bug睡的略爽 阅读(199) 评论(0) 推荐(0)

Integer to Roman
摘要:Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 普及一下罗马计数法 The base I - 1 V - 5 X - 10 L - 阅读全文

posted @ 2014-09-15 22:23 bug睡的略爽 阅读(172) 评论(0) 推荐(0)

Regular Expression Matching
摘要:Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding elemen 阅读全文

posted @ 2014-09-15 20:45 bug睡的略爽 阅读(197) 评论(0) 推荐(0)

String to Integer (atoi)
摘要: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 阅读全文

posted @ 2014-09-15 15:27 bug睡的略爽 阅读(147) 评论(0) 推荐(0)

Add Two Numbers
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single 阅读全文

posted @ 2014-09-15 11:11 bug睡的略爽 阅读(177) 评论(0) 推荐(0)

Pow(x, n)
摘要:Implement pow(x, n). 这题主要考察分治法,这样效率就可达到O(logn) 需要注意的是:n>0时 n为偶数时 xn = xn/2 * xn/2,n为奇数时 xn = x(n-1)/2 * x(n-1)/2 * x n=0时 ,xn = 1 n<0时 xn = 1 / x-n 代码 阅读全文

posted @ 2014-09-07 22:27 bug睡的略爽 阅读(159) 评论(0) 推荐(0)

Implement strStr()
摘要:Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. 方法一:暴力破解,O(mn),超时,写了这段 阅读全文

posted @ 2014-09-07 21:32 bug睡的略爽 阅读(167) 评论(0) 推荐(0)

Edit Distance
摘要:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have 阅读全文

posted @ 2014-09-06 21:05 bug睡的略爽 阅读(138) 评论(0) 推荐(0)

Sqrt(x)
摘要:Implement int sqrt(int x). Compute and return the square root of x. 传说中的牛顿法,请查看百度百科 某人说我偷懒,那我就决定还是翻些资料出来比较好。。。 牛顿法主要用于两方面,一是求方程根,二是最优化处理。 求方程根的原理是利用泰勒 阅读全文

posted @ 2014-09-06 20:30 bug睡的略爽 阅读(204) 评论(0) 推荐(0)

Median of Two Sorted Arrays
摘要: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 阅读全文

posted @ 2014-09-06 16:50 bug睡的略爽 阅读(145) 评论(0) 推荐(0)

Minimum Window Substring
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBECOD 阅读全文

posted @ 2014-09-05 10:18 bug睡的略爽 阅读(192) 评论(0) 推荐(0)

Partition List
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文

posted @ 2014-09-04 10:50 bug睡的略爽 阅读(146) 评论(0) 推荐(0)

Reorder List
摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For 阅读全文

posted @ 2014-09-04 10:31 bug睡的略爽 阅读(145) 评论(0) 推荐(0)

Longest Common Prefix
摘要:Write a function to find the longest common prefix string amongst an array of strings. 这题很简单,直接依次比较即可,代码如下: 1 class Solution { 2 public: 3 string long 阅读全文

posted @ 2014-09-04 10:04 bug睡的略爽 阅读(148) 评论(0) 推荐(0)

Two Sum 系列
摘要:Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of t 阅读全文

posted @ 2014-09-03 21:17 bug睡的略爽 阅读(188) 评论(0) 推荐(0)

Search in Rotated Sorted Array
摘要:Search in Rotated Sorted Array Suppose a sorted array 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 阅读全文

posted @ 2014-09-03 16:32 bug睡的略爽 阅读(136) 评论(0) 推荐(0)

Interleaving String
摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbcac", ret 阅读全文

posted @ 2014-09-03 15:47 bug睡的略爽 阅读(156) 评论(0) 推荐(0)

Longest Valid Parentheses
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the lo 阅读全文

posted @ 2014-09-03 10:40 bug睡的略爽 阅读(235) 评论(3) 推荐(1)

Valid Parentheses
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文

posted @ 2014-09-02 11:21 bug睡的略爽 阅读(145) 评论(0) 推荐(0)

Generate Parentheses
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: " 阅读全文

posted @ 2014-09-02 09:58 bug睡的略爽 阅读(403) 评论(0) 推荐(0)

导航