上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 25 下一页
摘要: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example 1:Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9].Example 2:Given [1,2],[3,5],[ 阅读全文
posted @ 2013-07-18 20:38 冰点猎手 阅读(187) 评论(0) 推荐(0)
摘要: Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ 5 \ 6 思路; 展开后的树其实就是先根遍历的一个结果,不过注意是连... 阅读全文
posted @ 2013-07-16 22:34 冰点猎手 阅读(165) 评论(0) 推荐(0)
摘要: 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:"((()))", "(()())", "(())()", "()(())", "()()()" backtracking solution:class Solution {private : int n; 阅读全文
posted @ 2013-07-16 22:08 冰点猎手 阅读(208) 评论(0) 推荐(0)
摘要: Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "A 阅读全文
posted @ 2013-07-16 19:44 冰点猎手 阅读(219) 评论(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 阅读全文
posted @ 2013-07-15 21:07 冰点猎手 阅读(163) 评论(0) 推荐(0)
摘要: 一、伯克利加州大学伯克利分校http://webcast.berkeley.edu/courses.php作为美国第一的公立大学,伯克利分校提供了,可以跟踪最新的讲座。想看教授布置的作业和课堂笔记,可以点击该教授的网页,通常,他/她都会第一堂课留下网址。实在不行,用google搜搜吧! 伯克利的视频都是.rm格式,请注意转换 二、麻省麻省理工学院http://ocw.mit.edu/OcwWeb/web/courses/courses/index.htm麻省理工是免费开放教育课件的先驱,计划在今年把1800门课程的课件都放在网站上,提供课程与作业的PDF格式下载。三是,麻省理工只提供少数的.. 阅读全文
posted @ 2013-07-15 19:30 冰点猎手 阅读(328) 评论(0) 推荐(0)
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *//** * Definition for binary tree * str... 阅读全文
posted @ 2013-07-11 21:06 冰点猎手 阅读(159) 评论(0) 推荐(0)
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 * }; ... 阅读全文
posted @ 2013-07-11 20:45 冰点猎手 阅读(270) 评论(0) 推荐(0)
摘要: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]class Solution {private: vector> result; vector a ; public: void findResult(int n, int k, int num,int start... 阅读全文
posted @ 2013-06-21 00:42 冰点猎手 阅读(151) 评论(0) 推荐(0)
摘要: 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 removing the second node from the end, the linked list becomes 1->2->3->5.Note:Given n will always be valid.Try to do this in one pas 阅读全文
posted @ 2013-06-05 10:10 冰点猎手 阅读(141) 评论(0) 推荐(0)
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 25 下一页