• 38.9%

https://leetcode.com/problems/increasing-subsequences/description/

Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2 .

Note:

1. The length of the given array will not exceed 15.
2. The range of integer in the given array is [-100,100].
3. The given array may contain duplicates, and two equal integers should also be considered as a special case of increasing sequence.

https://discuss.leetcode.com/topic/76274/c-dfs-solution-using-unordered_set

C++ dfs solution using unordered_set

https://discuss.leetcode.com/topic/76367/evolve-from-intuitive-solution-to-optimal

Evolve from intuitive solution to optimal

This is similar to Subsets II.

O(n2^n) For each number, we can either take it or drop it. Duplicates are removed by set.

We can also generate all increasing subsequences by adding each number to the current sequencies iteratively and use set to remove duplicates.

We can do better by not generating duplicates. When adding a duplicate number to existing sequences, we don’t need to add to all sequences because that will create duplicate sequence. We only need to add to the sequences created since adding this number last time.

Duplicates can also be avoided in recursion. Starting from a given number, we pick the next number. We cache the numbers already tried to avoid duplicates.