码迷,mamicode.com
首页 >  
搜索关键字:solution    ( 11547个结果
LeetCode: Subsets [078]
class Solution { public: void dfs(vector<vector >&result, vectorcombination, vector&candidates, int kth, int k, int index2add){ // 当前正在确定组合中的第kth个数,将把候选集candidates中index2add索引位的值作为第kth个数加到组合中 combination.push_back(ca...
分类:其他好文   时间:2014-06-07 01:21:47    阅读次数:220
Combinations
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...
分类:其他好文   时间:2014-06-04 20:02:13    阅读次数:228
Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ...
分类:其他好文   时间:2014-06-03 13:53:21    阅读次数:309
LeetCode Merge K Sorted Lists
class Solution {public: ListNode *mergeKLists(vector &lists) { ListNode* merged = NULL; for (int i=0; ival val) { n...
分类:其他好文   时间:2014-06-03 13:26:43    阅读次数:219
HDU 1015 dfs回溯
题目真长。。。。。看了好长时间才看懂。。就是给你一个32位数字和一个最多15个字符的字符串,从字符串中选出5个字符,若满足题中给的那个式子,输出字典序最大的那5个字符,若不满足,输出no solution。为了解决字典序问题,在输入字符串后,把字符串按从大到小排一下序,搜索一下若满足条件输出即可。贴...
分类:其他好文   时间:2014-06-03 13:07:48    阅读次数:200
LeetCode Merge Sorted Array
class Solution {public: void merge(int A[], int m, int B[], int n) { int mi = m + n - 1; int ai = m - 1; int bi = n - 1; ...
分类:其他好文   时间:2014-06-03 12:57:28    阅读次数:217
LeetCode Merge Intervals
class Solution {private: static int compare(const Interval& a, const Interval& b) { return a.start merge(vector &intervals) { vector...
分类:其他好文   时间:2014-06-03 12:32:23    阅读次数:228
LeetCode --- Valid Palindrome
题目链接判断字符串是否为回文串。附上代码: 1 class Solution { 2 public: 3 bool isPalindrome(string s) { 4 if (s.empty()) return true; // consider empty string ...
分类:其他好文   时间:2014-05-30 21:48:12    阅读次数:347
Leetcode: Triangle
这道题还是挺难的一道题,想法很重要 1 public class Solution { 2 public int minimumTotal(List> triangle) { 3 int size = triangle.size(); 4 int[] leve...
分类:其他好文   时间:2014-05-30 18:22:50    阅读次数:249
Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil...
分类:其他好文   时间:2014-05-30 16:17:49    阅读次数:210
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!