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.

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 originally consecutive elements.

303 questions
2
votes
3 answers

How to extract non-empty values from each column of a dataframe and make a list?

I have a dataset like below and want to extract non-empty cells from each column while keeping the Date information. df <- structure(list(Date = as.Date(c("6/25/2020", "6/26/2020", "6/27/2020"), format = "%m/%d/%y"), A = c("",2L,1L),B =…
T-T
  • 693
  • 1
  • 10
  • 24
2
votes
1 answer

Complete subsequence in Traminer

Subsequences functions give interesting results with the seqefsub function. I work on sequences composed of geographical locations. Is there a way to know whether the subsequence listed is a complete subsequence. I provide an…
F. Lyon
  • 77
  • 5
2
votes
1 answer

How do I get `[Element]` instead of `SubSequence` when dropping/removing elements?

If I remove elements from an array and store it in a variable like this: let lastFive = myArray.suffix(5) or this: let lastFive = myArray.dropLast(5) lastFive will be Array.SubSequence instead of the element type SomeType. How do I make…
Joakim Sjöstedt
  • 824
  • 2
  • 9
  • 18
2
votes
0 answers

Given array, find minimum number of element "moves" to the end so the sum of any contiguous subsequence starting at the first element is non-negative

Input is an array of integers, and a "move" is an operation removing a single element and placing it at the end of the array. Find the minimum number of moves so the sum of any contiguous subsequence starting at the first element is non-negative I…
guruguru
  • 21
  • 2
2
votes
1 answer

Store Subsequences in list of lists using recursion in python

This may sound very simple, I tried searching for the solution but couldn't find it hence posting the question. Appreciate the help, Thanks in advance. I am trying to print all the subsequences of a given list/string in python using recursion. Below…
Dev Solanki
  • 101
  • 1
  • 1
  • 9
2
votes
4 answers

Find the longest contiguous alternating sequence

Lets say we have an array {1, 1, 2, 3, 6, 5, 5, 4, 6} Find the longest contiguous odd/even or even/odd subsequence in the array. Answer is 5: {1, 2, 3, 6, 5} My idea is to find two subsequence starting number is odd starting number is even return…
2
votes
1 answer

R - Find all sequences and their frequencies in a data frame

Please, I have this data.frame: 10 34 35 39 55 43 10 32 33 40 45 48 10 35 36 38 41 43 30 31 32 34 36 49 39 55 40 43 45 50 30 32 35 36 49 50 2 8 9 39 55 43 1 2 8 12 55 43 2 8 12 55 43 61 2 8 55…
2
votes
2 answers

No of Subsequences without duplicates

I have an array of certain length (say 8) 1,2,2,3,3,4,5,6 I wish to find number of subsequences of this array of length (say 4). This is 8 choose 4 (8C4) = 70. However, in the list of 70 subsequences above, I do not want to count sequences having…
Ranon
  • 99
  • 4
2
votes
2 answers

How many sub-sequences of unique elements can be possible?

I'v a sequence of integer number [A1, A2, A3.....AN] I'm trying to count all sub-sequences which contain at most K unique numbers. For Example: Given sequence:: [2, 3, 3, 7, 5] and K = 3 All sub-sequences are: [], [2],[3],[3],[7],[5], [2, 3],[2,…
Afrin
  • 31
  • 7
2
votes
2 answers

DNA subsequence dynamic programming question

I'm trying to solve DNA problem which is more of improved(?) version of LCS problem. In the problem, there is string which is string and semi-substring which allows part of string to have one or no letter skipped. For example, for string "desktop",…
Choi Yeong
  • 23
  • 3
2
votes
2 answers

Find Subsequence in a String

I have been solving this set of a challenge on Hackerrank, link : Hackerrank in a String I have come up with my Algo which goes like this : To check whether it has atleast two a's, r's and k's according to the hackerrank string Check that it…
Alok
  • 8,452
  • 13
  • 55
  • 93
2
votes
3 answers

Maximum sum of contiguous sub-sequence with length at most k

I am trying to modify the Kadane Algorithm in order to solve a more specific problem. def max_Sum(arr, length, k): if length < k: print('length of array should be greater than k') res = 0 for i in range(0, k): res += arr[i] current_sum =…
rockmyboat
  • 157
  • 2
  • 10
2
votes
2 answers

Increasing Subsequence Recursive Java

I have the following problem: A sequence of numbers is said to be monotonically increasing (or simply increasing) if every number in the sequence is greater than, or equals to, the number preceding it. write a boolean function increasing(int[] x,…
Yuki1112
  • 365
  • 2
  • 12
2
votes
3 answers

Minimum length subsequence with positive sum <= K

The opposite question: Maximum length subsequence with positive-sum <= K is in fact the standard 01 Knapsack problem. The solution for it is pretty straightforward: int solve(const vector &A, int K) { int dp[A.size()+1][K+1]; int…
2
votes
3 answers

How to identify repeated subsequences in a dataset

I have a dataset of numerical values, each represent a zone. eg. x <- c(1,6,1,2,3,4,5,8,5,9,10,1,2,3,10,7,5,9,4,1,2,3) I need to identify whether there are repeated subsequences within the data, i.e whether the subject repeatedly travelled from…
Melanie
  • 21
  • 1