---
title: Longest Run Subsequence Problem
url: https://www.emergentmind.com/topics/longest-run-subsequence-problem
type: topic
---

# Longest Run Subsequence Problem

The **Longest Run Subsequence (LRS) problem** asks, for a string \(s \in \Sigma^*\), for a maximum-length subsequence \(t\) such that each symbol \(a \in \Sigma\) appears in \(t\) in at most one run, equivalently, all occurrences of \(a\) in \(t\) form a single contiguous block in \(t\). Introduced in the context of the scaffolding phase of genome assembly, the problem lies at the intersection of subsequence optimization, run-structured combinatorics, and parameterized complexity. Its known theory combines NP-hardness, fixed-parameter tractability under several parameterizations, kernelization lower bounds, approximation and inapproximability results, and both exact and metaheuristic solution approaches [2011.08119].

## 1. Formal definition and equivalent views

Let \(\Sigma\) be a finite alphabet and let \(s \in \Sigma^*\) be a string of length \(n\), written \(s = s_1 s_2 \dots s_n\). A run of \(s\) is any interval \([i,j]\), \(1 \le i \le j \le n\), such that \(s_i = s_{i+1} = \dots = s_j\), and \((i = 1 \text{ or } s_{i-1} \neq s_i)\) and \((j = n \text{ or } s_{j+1} \neq s_j)\). An \(a\)-run is a run whose symbol is \(a \in \Sigma\) [2011.08119].

A subsequence \(t\) of \(s\) is specified by strictly increasing indices \(1 \le i_1 < i_2 < \dots < i_\ell \le n\) with \(t = s_{i_1} s_{i_2} \dots s_{i_\ell}\). Runs in the subsequence are defined with respect to adjacency within \(t\): a run in \(t\) is a maximal block of equal symbols appearing consecutively in \(t\), not necessarily consecutive in \(s\). The LRS optimization problem asks for a maximum-length subsequence \(t\) of \(s\) such that each symbol \(a \in \Sigma\) appears in \(t\) in at most one run. The decision version, parameterized by a target length \(k\), asks whether there exists a subsequence \(t\) of length at least \(k\) such that, for every \(a \in \Sigma\), the occurrences of \(a\) in \(t\) are contained in a single run.

An equivalent characterization uses run-length encoding. Any LRS solution \(t\) decomposes into at most one run per symbol, and the sequence of run symbols is repetition-free. Thus \(t\)'s run-length encoding uses each symbol at most once. This formulation makes clear that a run picked in the solution need not be maximal in the input string, and not every symbol must appear. For example, for \(s = a b a c a a b b a b\), an optimal LRS is \(t = a a a a b b b\), which selects non-maximal runs for \(a\) and \(b\) and omits \(c\) [2011.08119].

A later formulation compresses the input into its maximal constant-letter substrings \(R = \{r_1,r_2,\dots,r_m\}\), ordered by occurrence in \(s\), where each run \(r_i\) has letter \(c(r_i)\) and length \(l(r_i)\). Under this view, if an optimal LRS subsequence includes any letter from a given run in \(s\), it includes all letters of that run. Hence a valid LRS solution can be expressed as a subset \(R' \subseteq R\) subject to the condition that if \(r_i, r_k \in R'\) with \(i < k\) and \(c(r_i)=c(r_k)\), then there is no \(r_j \in R'\) with \(i < j < k\) and \(c(r_j) \neq c(r_i)\). The objective becomes
\[
\max_{R' \subseteq R} \quad f(R') \;=\; \sum_{r_i \in R'} l(r_i).
\]
This run-based simplification is the basis for later ILP and metaheuristic methods [2508.14020].

## 2. Genome-assembly motivation and relation to adjacent problems

LRS was introduced recently in the context of the scaffolding phase of genome assembly. In scaffolding, bins in one assembly are matched to contigs in another. Errors and structural variations cause a contig to appear scattered across bins. LRS seeks a longest subsequence of contig matches in which every contig appears in at most one contiguous block, filtering out inconsistent mappings and suggesting a plausible partition into contigs. This directly captures the expectation that, in a correctly scaffolded ordering, each contig should appear as a single block [2011.08119].

The problem is distinct from classical order-constrained subsequence problems. Longest Increasing Subsequence imposes an order constraint on subsequences, whereas LRS imposes a run-contiguity constraint per symbol. It is also distinct from standard run-length encoded string problems, where runs are computational units for problems such as LCS on run-length encoded inputs. LRS operates on a single string and restricts the subsequence to at most one run per symbol, which makes selection combinatorial and NP-hard [2011.08119].

The restriction is also different from problems based on repeated motifs. The Longest Subsequence-Repeated Subsequence problem allows repeated units \(x_i\) that are arbitrary subsequences and does not restrict a letter to appear in only one block globally, whereas LRS requires at most one run per symbol. This difference is structurally important: LSRS is reported as polynomial-time solvable in \(O(n^6)\) for the unconstrained version, while LRS is NP-hard [2304.06862]. This suggests that the global uniqueness-of-run constraint, rather than mere block structure, is the principal source of hardness.

## 3. Complexity landscape

The basic complexity status is established by two strands of results. First, LRS is NP-hard, as shown by Schrinner et al. in WABI 2020. Second, the problem is fixed-parameter tractable when parameterized by the alphabet size \(|\Sigma|\), via an algorithm that uses exponential space, yielding time \(f(|\Sigma|)\cdot n^{O(1)}\) for some computable \(f\) [2011.08119].

Dondi and Sikora strengthened the parameterized picture by proving fixed-parameter tractability with respect to a smaller parameter, namely the number of runs in the solution. Let \(r\) be the number of runs in a chosen subsequence. Then LRS is FPT parameterized by \(r\). They also established kernelization lower bounds: LRS admits no polynomial kernel when parameterized by \(|\Sigma|\) unless NP \(\subseteq\) coNP/poly, and, since \(r \le |\Sigma|\), the same lower bound follows for parameter \(r\) [2011.08119].

At the same time, there is a simple positive kernelization result for the solution-length parameter \(k\). If \(|\Sigma| \ge k\), one occurrence per symbol yields a solution of length \(k\). If some symbol occurs at least \(k\) times, then a run of that symbol of length \(k\) is a solution. Otherwise \(|\Sigma| < k\) and each symbol occurs fewer than \(k\) times, so the total instance size is at most \(k\cdot|\Sigma| < k^2\). Thus LRS admits a polynomial kernel of size \(k^2\) when parameterized by \(k\) [2011.08119].

The approximation landscape is similarly mixed. A simple \(\sqrt{|s|}\)-approximation is obtained by comparing two candidates: the solution taking one occurrence per symbol, of length \(|\Sigma|\), and the longest \(a\)-run, of length equal to the maximum symbol frequency. The better of these is a \(\min(|\Sigma|,\mathrm{occ})\)-approximation, which yields a \(\sqrt{|s|}\) factor in the worst case. Against this upper bound stands a strong negative result: even when each symbol appears at most twice in the input string, LRS remains APX-hard, ruling out a PTAS unless \(P=NP\) [2011.08119].

A later paper places these results into a broader algorithmic picture, noting additionally that Asahiro et al. provided approximation algorithms under \(k\)-occurrence constraints, specifically \((k+1)/2\), and \(4/3\) when \(k=2\) [2508.14020].

## 4. Randomized FPT algorithm parameterized by the number of runs

The FPT algorithm for parameter \(r\) is based on a reduction to \(k\)-Multilinear Detection (k-MLD) through an arithmetic-circuit encoding. The theorem states: there exists a randomized algorithm that, given \(s\) and integers \(k,r\), decides if there exists a run subsequence of length \(k\) with exactly \(r\) runs in time
\[
O(2^r \cdot r \cdot |s|^3)
\]
and polynomial space. By iterating over \(k\), this solves the version with target length at least \(k\) [2011.08119].

The construction introduces one variable \(x_a\) per alphabet symbol \(a \in \Sigma\), and dynamic-programming circuit nodes \(P_{i,l,h}\) encoding the statement that there exists an LRS subsequence within \(s[1..i]\) of length \(h\) with exactly \(l\) runs. The root is \(P = P_{|s|,r,k}\). The recurrence is
\[
P_{i,l,h} = P_{i-1,l,h} \;+\; \sum_{j=1}^{i-1} \;\sum_{z=1}^{i-j-1} \Big( P_{j,l-1,h-z} \cdot x_a \Big)
\quad \text{where } s[i]=a \in \Sigma \text{ and } s[j+1..i] \text{ contains an $a$-run of length } z.
\]
The base cases are
\[
P_{i,0,0} = 1 \text{ for } i \ge 0; \quad P_{0,l,h} = 0 \text{ for } l>0 \text{ or } h>0.
\]

The recurrence has a direct combinatorial interpretation. The term \(P_{i-1,l,h}\) skips position \(i\). The summation adds a new terminal run on symbol \(a\), of length \(z\), after a feasible prefix with \(l-1\) runs and length \(h-z\). Multiplication by \(x_a\) marks the use of symbol \(a\); multilinearity then enforces that each symbol is used in at most one run globally.

Correctness is captured by the key lemma: there exists a run subsequence of \(s\) of length \(h\) consisting of \(l\) runs over distinct symbols \(\{a_1,\dots,a_l\}\) if and only if the circuit contains a degree-\(l\) multilinear monomial \(x_{a_1}\cdots x_{a_l}\) in \(P_{i,l,h}\), and hence in \(P_{|s|,r,k}\) for \(i=|s|\), \(l=r\), \(h=k\). The algorithm then invokes the Koutis–Williams randomized algorithm for k-MLD, which solves k-MLD on a circuit \(C\) in randomized time \(O(2^k \cdot |C|)\) and space \(O(|C|)\). Since the circuit size is \(O(|s|\cdot r \cdot k)\), iterating over all \(k \in [r,|s|]\) yields total time \(O(2^r \cdot r \cdot |s|^3)\) and polynomial space [2011.08119].

This algorithm is algebraic rather than combinatorial in the usual DP sense. A plausible implication is that its main significance is structural: it shows that the decisive combinatorial bottleneck is the number of symbol-blocks in the solution, not the input alphabet alone.

## 5. Kernelization lower bounds and hard restricted variants

The kernelization lower bounds are obtained by OR-cross-composition from unparameterized LRS to its parameterized variants. For parameter \(|\Sigma|\), given \(t\) instances \((s_i,\Sigma_i,k_i)\), equalized by length \(n\), alphabet size \(m\), and target \(k\), all alphabets are relabeled to \(\{1,\dots,m\}\), and a new instance is built over
\[
\Sigma' = \{1,\dots,m\} \cup \{\#, \$\}
\]
with string
\[
s' = \$^{2n} \,\sigma(s_1)\, \#^{2n} \,\$^{2n}\, \sigma(s_2)\, \#^{2n} \,\dots\, \$^{2n}\, \sigma(s_t)\, \#^{2n},
\]
and target
\[
k' = k + (t+1)(2n).
\]
The separator blocks force any feasible solution to use exactly one run on \(\$\) and one run on \(\#\), and to be contained within exactly one block \(\sigma(s_i)\). Hence \(s'\) has an LRS of length at least \(k'\) if and only if at least one original instance does. Since \(|\Sigma'|=m+2\), the cross-composition implies that LRS admits no polynomial kernel parameterized by \(|\Sigma|\) unless NP \(\subseteq\) coNP/poly [2011.08119].

The corollary for parameter \(r\) is immediate from \(r \le |\Sigma|\): LRS has no polynomial kernel parameterized by the number of runs unless NP \(\subseteq\) coNP/poly. These results sharply separate fixed-parameter tractability from kernelizability for the most natural structural parameters.

The APX-hardness result shows that the difficulty persists under a severe frequency restriction. When each symbol appears at most twice in the input string, LRS remains APX-hard via an L-reduction from Maximum Independent Set on cubic graphs. The construction uses vertex symbols \(w_i\), edge-related symbols \(x_{i,j}^i\), \(x_{i,j}^j\), separators \(e_{i,j}^1,e_{i,j}^2\), and separator triplets \(\mathrm{sharp}_{p,z}\). Canonical subsequences can be enforced so that each vertex gadget contributes either \(w_iw_i\) or an \(x\)-heavy block, and edge gadgets enforce consistency: adjacent vertices cannot both contribute \(w_iw_i\). The reduction has constants \(\alpha = 65\) and \(\beta = 1\), and therefore LRS with at most two occurrences per symbol is APX-hard and admits no PTAS unless \(P=NP\) [2011.08119].

A later paper uses this restricted-case hardness as part of a practical algorithmic motivation: exact methods such as ILP and DP may solve only modest-size instances, making heuristics and metaheuristics natural for scalability [2508.14020].

## 6. Exact formulations, heuristic methods, and empirical performance

A compact integer linear programming model, reported from Schrinner et al., uses one binary variable \(x_i\) for each run \(r_i \in R\):
\[
x_i \in \{0,1\} \quad \text{(select run } r_i \text{)}.
\]
The objective is
\[
\max \sum_{r_i \in R} l(r_i)\,x_i,
\]
and validity is enforced by constraints stating that if two selected runs of the same letter are chosen, then no selected run of a different letter may lie between them:
\[
\sum_{\substack{i < \ell < j \\ c(r_\ell) \neq c(r_i)}} x_\ell
\;\;\le\;\;
\big(2 - x_i - x_j\big)(j-i)
\quad
\forall \; 1 \le i < j \le m \;\text{ with } c(r_i)=c(r_j).
\]
If \(x_i=x_j=1\), the right-hand side is \(0\), so all intervening foreign-letter runs are forbidden; if at least one endpoint is unselected, the constraint becomes nonbinding. This model enforces that, for each letter \(a\), the selected run indices carrying \(a\) form a contiguous block [2508.14020].

The same paper presents a **Biased Random Key Genetic Algorithm (BRKGA)** and a **Max–Min Ant System (MMAS)** for LRS. In the BRKGA, an individual is a vector \(\pi \in [0,1]^m\), one key per run. Decoding sorts runs by non-increasing key and greedily adds them if validity is preserved. The validity check is implemented with per-letter lower and upper bounds, \(LB(a)\) and \(UB(a)\), initialized to \(-1\). For a candidate run \(r_{\sigma(i)}\) with letter \(\alpha\), insertion is allowed only if, for every \(a \neq \alpha\), the three conditions
\[
\neg\big(\sigma(i) > LB(a) \;\land\; \sigma(i) < UB(a)\big),
\]
\[
\neg\big(\sigma(i) < LB(a) \;\land\; LB(\alpha) > UB(a)\big),
\]
\[
\neg\big(\sigma(i) > UB(a) \;\land\; UB(\alpha) < LB(a)\big)
\]
all hold. If accepted, \(LB(\alpha)\) and \(UB(\alpha)\) are updated. The fitness is
\[
f'(\pi)=\sum_{r_i \in R_\pi} l(r_i).
\]
Evaluation cost is \(O(m\log m + m|\Sigma|)\), and measured decoding times are generally well below \(1\) ms, with only a few evaluations for \(n=5000\) slightly exceeding \(1\) ms [2508.14020].

The reported BRKGA parameters are population size \(\mathrm{pop}=356\), elite fraction \(\mathrm{prop}_e=0.18\), mutant fraction \(\mathrm{prop}_m=0.29\), and crossover probability \(\mathrm{elite\_prob}=0.69\). The MMAS comparator uses one pheromone per run, learning rate \(\rho=0.33\), \(10\) solution constructions per iteration, and determinism rate \(\delta=0.92\). CPLEX 22.1 is used on the ILP model in sequential mode, under the same time limit \(n/10\) CPU seconds per instance [2508.14020].

The experiments use \(1050\) uniformly random instances: for each \(n \in \{100,200,300,500,1000,2000,5000\}\) and \(|\Sigma| \in \{2,4,8,16,32\}\), \(30\) instances are generated. Across all \(1050\) instances, BRKGA obtains the best solution quality on average and outperforms MMAS and CPLEX with statistical significance. For \(|\Sigma|=2\), BRKGA and MMAS reach the same average best values, but MMAS requires notably more time. As \(|\Sigma|\) increases, MMAS degrades markedly relative to BRKGA. For the shortest strings, \(n=100\) with \(|\Sigma| \in \{16,32\}\), CPLEX produced slightly better solutions within the time limit than BRKGA. CPLEX solved only the smallest or easiest cases to near-optimality, and its optimality gaps grew rapidly with \(n\) and \(|\Sigma|\) [2508.14020].

These results do not alter the formal complexity picture, but they clarify the present methodological split. Exact formulations remain useful on small instances, while large-instance practice currently relies on run-compressed representations and extremely fast validity-preserving decoding.

## 7. Open directions

The open problems explicitly highlighted include improving approximation algorithms beyond the trivial \(\sqrt{|s|}\) bound and closing the gap with APX-hardness; evaluating the practical competitiveness of the randomized multilinear-detection FPT algorithm against ILP formulations and heuristics; and further exploration of parameterizations and structural restrictions that might yield efficient exact or approximation algorithms [2011.08119].

The later BRKGA study isolates a concrete practical limitation: performance on short strings with large \(|\Sigma|\), where CPLEX can still be competitive, and the absence of domain-informed heuristic information for improving the decoder beyond pure greedy feasibility. This suggests that the empirical frontier is no longer only about raw search power, but also about the quality of structure-aware decoding and hybrid exact-heuristic strategies [2508.14020].

Taken together, the current state of LRS is unusually well stratified. The formal side provides precise separations between NP-hardness, FPT solvability, kernel lower bounds, and APX-hardness. The algorithmic side provides both algebraic FPT machinery and run-based practical solvers. The remaining questions concern how closely these two perspectives can be brought together without weakening either exactness or scalability.

Source: https://www.emergentmind.com/topics/longest-run-subsequence-problem