Questions tagged [subsequence]
A subsequence is a sequence obtained by deleting some elements and retaining the relative order of the remaining elements. It is a generalization of substring which contains only consecutive elements of the original sequence.
subsequence
308
questions
1
vote
1
answer
87
views
Determine which elements of sequence A can be used to create given sequence B in linear time
Let's say we have sequence A and subsequence of A, called B. I need to determine which elements of sequence A could be potentially used to construct subsequence B.
For example, assume A = [1, 3, 2, 1, ...
3
votes
3
answers
159
views
Longest Repeating Subsequence: Edge Cases
Problem
While solving the Longest Repeating Subsequence problem using bottom-up dynamic programming, I started running into an edge case whenever a letter was repeated an odd number of times.
The goal ...
1
vote
2
answers
29
views
Longest sequence count and sequence to be returned
We need to print the longest sequence of nos.
Input = [2,3,4,5,8,0]
Output= 3,[2,3,4,5]
Input=[2,3,4,5,8,0,10,9,8,7,6,5]
Output= 5,[10,9,8,9,6,5]
Below is the code that I have written, can someone ...
1
vote
1
answer
36
views
Setting a minimum length for subsequences?
I'm using TraMineR to analyze the transitions between states over a 30 minute trial. There are 10 states, and then missing values, for the entire 108,000 frames. When I get the subsequences, it ...
1
vote
1
answer
133
views
Check if a string has a palindrome subsequence of length k
The string S consists of lowercase English letters. I want to know whether this string contains a palindrome subsequence of length exactly k or not. I want a dynamic programming algorithm that runs ...
0
votes
0
answers
38
views
Time Complexity of the Iterative Version of the Subsequence Question
What will be the time complexity of the Code below, as my teacher said the time complexity will be O(N2^N).
My question, as per my understanding of how T.C(which might be very wrong, so please don't ...
0
votes
2
answers
202
views
Increasing Tripplet Subsequence
I was attempting the Increasing Triplet Subsequence problem on leetcode.com
I started off with a brute force approach but it ran into time out issues but passing almost all testcases. The following is ...
1
vote
1
answer
217
views
Find occurrences of subsequence in a binary string (non-necessarily-contiguous)
Given a binary string with 0 and 1. I want to know number of occurrences of subsequences 01 and 10 in the given input String. Subsequences are not necessarily contiguous.
For example:
input : "...
0
votes
0
answers
49
views
Subsequence and subset of the array
I have a doubt between the subsequence and subset of the array.
Suppose I have an array:
nums = [1,2,3]
output = [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
Whether output contains subsequence or ...
0
votes
2
answers
102
views
NumPy: find indices of strictly increasing subsequence within an array
I am NOT looking to find the largest increasing subsequence.
I have a NumPy array similar to the following:
[0, 1, 5, 2, 4, 8, 8, 6, 10]
I need to find the indices of the elements that form a ...
3
votes
2
answers
1k
views
Number of subsequences of length 3 or more, such that the sum of its "middle" is equal to the values of its "endpoints"
Given an array of integers (length N), return the count of subsequences of length at least 3 (from 3 to N) such that the following conditions hold: the value of the first element of the subsequence ...
0
votes
0
answers
25
views
Why am I getting '[...]' as a subsequence of my input string? [duplicate]
I am trying to recursively obtain all subsequences for an input string. While I am getting the said subsequences, another element keeps getting added as well. I cannot figure out what is producing ...
0
votes
1
answer
144
views
Combination Sum code giving me incorrect answer
Problem (Combination Sum): Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. ...
0
votes
1
answer
256
views
Segmentation with piecewise linear regression
I am willing to segment a sequence into n subsequences (n known) where my points in each subsequence should be similar in a way that a piecewise linear function could fit the points (minimize the ...
0
votes
3
answers
44
views
How to copy all data in a table into the same table, but only changing one column to have subsequent numbers
I have to do the following and can't figure out how to do it all correctly:
I have a table test
Test1
Test2
1
ABC
2
DEF
I want to duplicate this, and have the test1 column have subsequent ...