这种increasing xxx 题真是老客户了.. 本题麻烦点在于不能重复, 但是和之前的那些 x sum的题目区别在于不能排序的

所以.... 我还是没搞定.

看了一个Java的思路是直接用set来存最终结果去重;  不太清楚Java的set自带比较函数? 用cpp的话就要为vector<int>编写hash函数...

cpp的方案有点特别, 每次递归的时候用一个哈希表记录有哪些数字已经用过了..很巧妙

class Solution {
public:
typedef vector<int> VI;
typedef vector<VI> VVI;
void traverse(VVI &out, VI &item, VI &src, int i)
{
unordered_set<int> si;
for(int j=i;j<src.size();++j)
{
if((item.empty()||src[j]>=item.back())&&si.find(src[j])==si.end())
{
item.push_back(src[j]);
    if(item.size()>)out.push_back(item);
traverse(out,item,src,j+);
item.pop_back();
si.insert(src[j]);
}
}
}
vector<vector<int>> findSubsequences(vector<int>& nums) {
VVI ret;
VI item;
traverse(ret,item,nums, );
return ret;
}
};

491. Increasing Subsequences的更多相关文章

  1. [LeetCode] 491. Increasing Subsequences 递增子序列

    Given an integer array, your task is to find all the different possible increasing subsequences of t ...

  2. 491. Increasing Subsequences增长型序列

    [抄题]: Given an integer array, your task is to find all the different possible increasing subsequence ...

  3. LeetCode 491. Increasing Subsequences

    原题链接在这里:https://leetcode.com/problems/increasing-subsequences/ 题目: Given an integer array, your task ...

  4. 【LeetCode】491. Increasing Subsequences 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

  5. 491 Increasing Subsequences 递增子序列

    给定一个整型数组, 你的任务是找到所有该数组的递增子序列,递增子序列的长度至少是2.示例:输入: [4, 6, 7, 7]输出: [[4, 6], [4, 7], [4, 6, 7], [4, 6, ...

  6. 【leetcode】491. Increasing Subsequences

    题目如下: 解题思路:这题把我折腾了很久,一直没找到很合适的方法,主要是因为有重复的数字导致结果会有重复.最后尝试用字典记录满足条件的序列,保证不重复,居然Accept了. 代码如下: class S ...

  7. Leetcode之深度优先搜索&回溯专题-491. 递增子序列(Increasing Subsequences)

    Leetcode之深度优先搜索&回溯专题-491. 递增子序列(Increasing Subsequences) 深度优先搜索的解题详细介绍,点击 给定一个整型数组, 你的任务是找到所有该数组 ...

  8. [LeetCode] Increasing Subsequences 递增子序列

    Given an integer array, your task is to find all the different possible increasing subsequences of t ...

  9. [Swift]LeetCode491. 递增子序列 | Increasing Subsequences

    Given an integer array, your task is to find all the different possible increasing subsequences of t ...

随机推荐

  1. Linux内核分析--进程创建,执行,切换

    学号:351 原创作品转载请注明出处本实验来源 https://github.com/mengning/linuxkernel/ 实验要求 从整理上理解进程创建.可执行文件的加载和进程执行进程切换,重 ...

  2. SpringBoot 2.0 pom.xml 配置(热启动)

    <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven ...

  3. cocos2d-html5 碰撞检测的几种方法

    游戏中的碰撞还是比较多的,比如角色与角色的碰撞,角色与墙壁的碰撞,角色与怪物的碰撞等,都需要进行碰撞的检测,来触发一定的事件 最近在尝试制作一个小游戏的时候需要用到碰撞检测,然后就查了下资料,并在论坛 ...

  4. redis应用--位图

    在我们平时开发过程中,会有一些 bool 型数据需要存取,比如用户一年的签到记录,签了是 1,没签是 0,要记录 365 天.如果使用普通的 key/value,每个用户要记录 365 个,当用户上亿 ...

  5. bean shell 中parameter传递参数的方法

    1.在csv set data config中添加用到的数据文件,并进行配置 2.在这一栏中,可以引入数据文件中的数据,用法如下${变量名},多个变量用空格隔开.在脚本中进行引用时,采用bsh.arg ...

  6. 重新复习~ 为了重新找工作 - > XMLHttpRequest2.0 Jsonp nodeType 节点 webpack基本搭建 闭包的一句话总结

    XMLHttpRequest2.0 1.可以设置超时 (xhr.timeout = 1000; ontimeout()函数) 2.支持FormData对象管理表单数据(new FormData 方法: ...

  7. 第2次作业 -- 熟悉 JUnit 测试

    2.1 Mooctest 使用心得 Mooctest很方便,可以即时测评自己写的测试代码,获得覆盖率和报告,不需要自己安装配置环境 而且安装配置插件的环境也很简单,可以专注于测试本身 2.2 Juni ...

  8. c# word interop encrypt with password protect with password

    public static void EncryptWithPassword(string unEncryptedWordPath, string password) { Word.Applicati ...

  9. 【亲测】Asp.net Mvc5 + EF6 code first 方式连接MySQL总结

    本文原文地址为:https://www.cnblogs.com/summit7ca/p/5423637.html 原文测试环境为windows 8.1+Vs2013+MySql5.7.12 本人在wi ...

  10. 收藏nginx学习

    http://blog.csdn.net/u012186351/article/details/50605672 http://blog.csdn.net/qq_25371579/article/de ...