上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 34 下一页
摘要: Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, return1->2->3./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val 阅读全文
posted @ 2014-01-15 20:05 七年之后 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,IfS=[1,2,2], a solution is:[ [2], [1], [1,2,2], [2,2], [1,2], []]思考:直接set去重会不会太暴... 阅读全文
posted @ 2014-01-15 17:54 七年之后 阅读(209) 评论(0) 推荐(0) 编辑
摘要: Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not co... 阅读全文
posted @ 2014-01-15 14:18 七年之后 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]Have you been asked this question in an interview?Yesclass Solution {private: vector > res; vector ans;public: void ... 阅读全文
posted @ 2014-01-15 11:36 七年之后 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 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="ADOBECODEBANC"T="ABC"Minimum window is"BANC".Note:If there is no such window in S that covers all characters in T, return the emtpy 阅读全文
posted @ 2014-01-14 22:19 七年之后 阅读(244) 评论(0) 推荐(0) 编辑
摘要: Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is greater than the last integer of the previous row.For example,Consider the following matrix:[ [1, 3, ... 阅读全文
posted @ 2014-01-14 15:13 七年之后 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a) Insert a characterb) Delete a characterc) Replace a character思考:DP。dp[i-1][j]+1:删除一个字符dp[i][j-1]+1:插入一个字符dp 阅读全文
posted @ 2014-01-14 15:01 七年之后 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cases.Corner Cases:Did you consider the case wherepath="/../"?In this case, you should return&quo 阅读全文
posted @ 2014-01-13 15:32 七年之后 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 一.Boosting和Bagging 首先,Boosting和Bagging两种算法都是通过构造一系列的预测函数,然后以某种方式将他们组合成最终的预测模型,以此来提高学习算法的准确度。 Bagging的主要思想是给定一个弱学习算法和一组训练集(x1,y1),…,(xn,yn)。让该学习算法训练多... 阅读全文
posted @ 2014-01-13 13:42 七年之后 阅读(2570) 评论(0) 推荐(0) 编辑
摘要: Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces' 'when necessary so that each line 阅读全文
posted @ 2014-01-12 21:38 七年之后 阅读(377) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 34 下一页