308 questions
5
votes
2
answers
144
views
Algorithm to select multiple non-overlapping subsequences of given sequence
You have been given the input data (a sequence of items), for example:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
and your task is to randomly select M non-overlapping samples (...
4
votes
1
answer
456
views
How to find the longest increasing subsequence in a circular buffer?
I am trying to solve a sorting problem in which it would be useful to determine the longest increasing subsequence in a circular buffer.
As an example, let's take the following sequence:
5, 3, 4, 2, 1
...
1
vote
1
answer
131
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
345
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
36
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
61
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
298
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
41
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
749
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
512
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
2
answers
156
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
27
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
173
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
407
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 ...