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
0
votes
2 answers

Finding and counting all subsequence of a string

I'm trying to find all possible sub-sequence of a string. For example "abc" in this string we will find total 8 string 2^3=8 combinations. like a, b, c, ab, ac, bc, abc '\0'. But my code is only printing all character of the string. How can I do…
user3673621
  • 11
  • 1
  • 1
0
votes
0 answers

Subsequence as primary key

I have a scenario where I need to generate a batch number (primary key) in the below format. Batch Number: ( X X ) ( X X X X X ) Location Sequence Eg: 0100001 0100002 0200001 …
0
votes
1 answer

Array list and finding the longest subsequence with the same number

I was wondering what would be the best way to implement this. Can't think of a good way to save what information that needs to be saved like the index and the number of values and finally the actual number that get's repeated public class testing…
user3307265
  • 35
  • 2
  • 7
0
votes
1 answer

Deterministic automata to find number of subsequence in string of another string

Deterministic automata to find number of subsequences in string ? How can I construct a DFA to find number of occurence string as a subsequence in another string? eg. In "ssstttrrriiinnngggg" we have 3 subsequences which form string "string" ? also…
io10
  • 45
  • 8
0
votes
5 answers

What is the best way to test a list contain another list (w/o gap) in python?

Suppose that I have a list x=[1, 2, 3, 4], it contains the sublists [1], [2], [3], [4], [1, 2], [2, 3], [3, 4], [1,2,3], [2,3,4] and [1,2,3,4]. But it does not contain something like [1, 3] because there is a gap as 2 appears between 1 and 3 in…
user1424739
  • 11,937
  • 17
  • 63
  • 152
0
votes
1 answer

I need to convert a void out put into a string so that i can compare the two strings

My program is supposed to generate a pattern of letters based on the input of the user. I have to use recursion to set each output to be different. I've already done this. Next i have to compare the two outputs in another method and use recursion to…
-1
votes
1 answer

Find all possible patters in list of no and the position of the pattern break

input has list of nos output has all the possible pattern occurring and the position where the pattern break input [1,2,3,1,2,3,1,2,3,4,1,2,3,10,5,6,4,5,6,8,4,5,6,12,2,3] output [1,2,3]: 10th position and 14th [4,5,6]:20th position and…
KS HARSHA
  • 67
  • 2
  • 7
-1
votes
2 answers

Determine possibilities where all elements in a list are present and in the same order as in another list

The problem e.g. list1 = ["a", "c", "b", "a", "b", "c", "a", "c", "b"] list2 = ["a", "c", "a", "b"] Possibilities: 1. list1 = ["a", "c", "b", "a", "b", "c", "a", "c", "b"] list2 = ["a", "c", "a", "b"] those are indexes: [1, 2, 4, 5 2. list1 = ["a",…
-1
votes
4 answers

Fast python way to check if subsequence exists in a string and allow for 1-3 mismatches?

I am wondering if there is a fast Python way to check if a subsequence exists in a string, while allowing for 1-3 mismatches. For example the string: "ATGCTGCTGA" The subsequence "ATGCC" would be acceptable and return true. Note that there is 1…
-1
votes
1 answer

Print Subsequences of given length "k" from an Array

Getting Runtime error for this code :- import numpy as np def combination(inp,n,k,ans): if len(ans)==k: print(*ans) else: if len(inp)>0: b=[] b=ans.append(inp[0]) …
-1
votes
3 answers

How to solve the duplicate integer issue in an array for the isValidSubsequence(array, sequence) question

prompt for isValidSubsequence def isValidSubsequence(array, sequence): index = -1 # issue is with initialising the index variable if len(sequence)<=len(array): for i in range(len(sequence)): # i refers to the i in the…
-1
votes
2 answers

How to create array by user input?

I have a C++ problem: Input an sequence of digit [ 0 - 9 ] and terminated by three 9 consecutivly, print on standard output the number of subsequences consisting of three consecutive equal digits on standard output. Example: Given the sequence { 1…
aprilio
  • 11
  • 1
  • 5
-1
votes
2 answers

runtime error: addition of unsigned offset to 0x7ffeba23a6e0

Here is my code, I wrote it on leetcode platform const int N1 = 100+1; const int N2 = 10e4+1; class Solution { public: bool cache[N1][N2]; bool isSubsequence(string s, string t) { int n1 = s.size(); int n2 = t.size(); …
Shubham Singh
  • 90
  • 1
  • 8
-1
votes
1 answer

Coursera : unknown signal 11 by autograder

I have this piece of code for Longest Common Sub-sequence problem (I am doing it by Dynamic Programming method) But I am getting error by the Coursera Autograder (Failed case #6/37: unknown signal 11 (Time used: 0.00/1.00, memory used:…
-1
votes
2 answers

Longest Common Subsequent output wrong result

I've been trying to solve the LCS problem using recursion like below: #include #include using namespace std; string max(string x, string y) { return x.size() <= y.size() ? y : x; } string find(string x, string y) { //…
Hieu Na
  • 31
  • 5