上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 20 下一页

[LeetCode] Unique Binary Search Trees, Solution

摘要: Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's... 阅读全文
posted @ 2013-03-21 10:48 小刀初试 阅读(137) 评论(0) 推荐(0)

[LeetCode] Remove Duplicates from Sorted List II, Solution

摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2-... 阅读全文
posted @ 2013-03-19 10:48 小刀初试 阅读(150) 评论(0) 推荐(0)

[LeetCode] Search a 2D Matrix, Solution

摘要: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted fr... 阅读全文
posted @ 2013-03-18 05:44 小刀初试 阅读(135) 评论(0) 推荐(0)

[LeetCode] Merge Two Sorted Lists, Solution

摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.» Solve... 阅读全文
posted @ 2013-03-17 05:06 小刀初试 阅读(185) 评论(0) 推荐(0)

恩,我用了double...精度比float更高,所以没出溢出问题。

摘要: 恩,我用了double...精度比float更高,所以没出溢出问题。 阅读全文
posted @ 2013-03-17 01:42 小刀初试 阅读(181) 评论(0) 推荐(0)

我也写了一个牛顿迭代法,貌似不需要特殊处理溢出的情况 class Solution { public...

摘要: 我也写了一个牛顿迭代法,貌似不需要特殊处理溢出的情况class Solution {public:int sqrt(int x) {if (x ==0) return 0; double pre_t; double cur_t = 1; ... 阅读全文
posted @ 2013-03-17 01:38 小刀初试 阅读(514) 评论(0) 推荐(0)

[LeetCode] Longest Valid Parentheses, Solution

摘要: Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the lon... 阅读全文
posted @ 2013-03-11 11:54 小刀初试 阅读(130) 评论(0) 推荐(0)

[LeetCode] Two Sum, Solution

摘要: 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 the two nu... 阅读全文
posted @ 2013-03-05 12:34 小刀初试 阅读(166) 评论(0) 推荐(0)

[LeetCode] Palindrome Partitioning II, Solution

摘要: 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 ... 阅读全文
posted @ 2013-03-05 11:57 小刀初试 阅读(137) 评论(0) 推荐(0)

[LeetCode] Palindrome Partitioning, Solution

摘要: 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,... 阅读全文
posted @ 2013-03-04 12:52 小刀初试 阅读(121) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 20 下一页