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
1
vote
1 answer

finding the subsequence of strings in c# urjent

Alice has two strings, initial and goal. She can remove some number of characters from initial, which will give her a subsequence of that string. A string with no deletions is still considered a subsequence of itself. Given these two strings, can…
1
vote
3 answers

Find the repeated sequence in the line that go in a row

Given a string of arbitrary length. I need to find 1 subsequences of identical characters that go in a row. My function (there are two of them, but these are two parts of the same function) turned out to be complex and cumbersome and did not fit…
Coffee inTime
  • 231
  • 1
  • 8
1
vote
1 answer

Longest increasing subsequence with K exceptions allowed

Hello I am stuck with my homework which is: given sequence of integers, find the longest subsequence whose elements are ordered in an increasing order. Up to k exceptions that means at most k times, the next number in the sequence is smaller than…
KarmaL
  • 11
  • 3
1
vote
2 answers

Count Subsequences with absolute difference of first and last element smaller <= K

I faced this problem in a hackathon but couldn't figure out where I was going wrong. The problem statement was Count the number of subsequences in an array where the difference of the first and last element is <= K Each subsequence is…
Ankit Sharma
  • 1,626
  • 1
  • 14
  • 21
1
vote
1 answer

How to rank subsequent data with gaps

I have this table that I want to rank and update the plan_number column. Using DENSE_RANK I have managed to group most of the data but some of the accounts have an amount that is the same before and after a gap they will be grouped together. CREATE…
Djuric
  • 45
  • 4
1
vote
2 answers

Longest Ordered Subsequence of Vowels - Dynamic Programming

Given a string consisting of only vowels, find the longest subsequence in the given string such that it consists of all five vowels and is a sequence of one or more a’s, followed by one or more e’s, followed by one or more i’s, followed by one or…
1
vote
2 answers

Longest sub array in rotating array

Is there any way to find the longest subarray of 1's in log(n) time? example: 110011111000 - then the output is 5 (from pos 5 to 10) 1110011101 - the output here is 3 but after rotation 1 the array becomes 111100111 and the output is now 4. 001111…
Mike3096
  • 41
  • 9
1
vote
1 answer

maximum of minimum of difference in subsequence of k size

Given a sorted sequence of n elements. Find the maximum of all the minimums taken from all pairs differences of subsequences of length k. Here 1<=n<=10^5 and 2<=k<=n For eg: [2, 3, 5, 9] and k = 3 there are 4 subsequences: [2, 3, 5] - min diff of…
user1818277
  • 11
  • 1
  • 5
1
vote
2 answers

Algorithm if there is a string including subsequences A and B but not F

I'm looking for an efficient alogrithm for the following problem: We are given as input three strings A, B and F and we need to tell if there is a String X such that A and B are subsequences of X but F is not. The output of the algorithm should be…
tykkipeli
  • 146
  • 9
1
vote
2 answers

Recursive function to find the number of continuous sub-sequences in an array having a sum in the given range

I wrote this code. The idea is to split the array into 2 parts and find the number of sub-sequences that satisfy the given condition. Now there can also be a sub-sequence with elements from both subarrays. Hence I wrote the crossub function. The…
Rohit Bajaj
  • 63
  • 1
  • 12
1
vote
1 answer

maximum subsequence in c++

Question: Where is the error in my code? Promlem: I would like to find the maximum unique subsequence in a string. Example: For aabbaba the answer would be 2 (ab or ba). I would like to do that by iterating the string only once. Only lower-case…
User12547645
  • 6,955
  • 3
  • 38
  • 69
1
vote
1 answer

Match character sequence in two strings

I have the following problem: a <- "blablabla_string_to_extract_qwertz" b <- "werwer_qweqweq_string_to_extract_nnmn" d <- c("hello", "This is nonsense", b) Now I like to test in vector d, whether there is an entry that contains a sequence of…
Markus
  • 101
  • 1
  • 7
1
vote
1 answer

BigQuery to find the Subsequence

Assuming my table is WITH `sample_project.sample_dataset.table` AS ( SELECT 'user1' user, 2 sequence, 'T1' ts UNION ALL SELECT 'user1', 2, 'T2' UNION ALL SELECT 'user1', 1, 'T3' UNION ALL SELECT 'user1', 1, 'T4' UNION ALL SELECT 'user1',…
phaigeim
  • 729
  • 13
  • 34
1
vote
0 answers

Count Different Palindromic Subsequences

Source Leetcode Given a string S, find the number of different non-empty palindromic subsequences in S, and return that number modulo 10^9 + 7. A subsequence of a string S is obtained by deleting 0 or more characters from S. A sequence is…
Atiq
  • 490
  • 11
  • 28
1
vote
1 answer

Generating increasing subsequences out of n numbers of length k

I want to generate all possible increasing subsequences of numbers (repetition allowed) from 1 to n, but of length k. Ex. n=3, k=2 Output: 1 1 1 2 1 3 2 2 2 3 3 3 This is my code: #include int s[100]; int n=6; int k=4; void subk(int…
Vijayraj S
  • 81
  • 1
  • 10