Papers
Topics
Authors
Recent
Search
2000 character limit reached

Maximum Feasible Substring under Pattern Supply

Updated 21 January 2026
  • MFSP is a combinatorial optimization problem that identifies the longest substring of a text meeting a pattern’s frequency (Parikh) constraints.
  • It employs a linear-time two-pointer sliding window method which dynamically adjusts the substring to maintain feasibility.
  • MFSP generalizes Abelian pattern matching, linking resource-budget interpretations with packing-style optimization in string analysis.

Maximum Feasible Substring under Pattern Supply (MFSP) is a combinatorial optimization problem arising in the context of frequency-based (Abelian/permutation/jumbled) pattern matching. Given a pattern PP and a text TT over a general alphabet Σ\Sigma, MFSP seeks the longest substring of TT whose symbol counts are bounded, component-wise, by those of PP. This exact resource-budget interpretation generalizes and connects standard Abelian pattern detection with packing-style primitives, and admits a linear-time solution via a two-pointer feasibility-maintenance algorithm (Shanto et al., 14 Jan 2026).

1. Formal Problem Definition

Let Σ\Sigma be an alphabet of size σ\sigma. Given a pattern P∈ΣmP \in \Sigma^m and a text T∈ΣnT \in \Sigma^n, denote the Parikh vector of a string SS by

TT0

for each TT1. The pattern's Parikh vector TT2 is interpreted as a supply or budget vector.

A substring TT3 is feasible if

TT4

or equivalently,

TT5

The Maximum Feasible Substring under Pattern Supply (MFSP) asks to find

TT6

The goal is to output the substring TT7, which has the maximum length TT8 under the component-wise Parikh budget constraint.

2. Linear-Time Two-Pointer Feasibility Algorithm

The core algorithmic insight is that feasibility under the Parikh budget constraint is monotone under left-shrinkage: when a window TT9 becomes infeasible at some Σ\Sigma0, increasing Σ\Sigma1 can only reduce or restore feasibility. The solution maintains the following:

  • Σ\Sigma2 for all Σ\Sigma3,
  • Σ\Sigma4 for all Σ\Sigma5 (running counts for the current window),
  • Σ\Sigma6 = the number of Σ\Sigma7 for which Σ\Sigma8 (violation counter).

For each iteration, after extending the right end Σ\Sigma9, the algorithm shrinks TT0 while TT1, ensuring each window TT2 is maximal and feasible. The substring of maximum feasible length is retained.

Pseudocode outline:

TT02

3. Proof Sketch: Correctness and Complexity

  • Feasibility Invariant: After the inner while (viol > 0), TT3 and so TT4 is feasible; each counter TT5 for all TT6.
  • Window Maximality: For each TT7, shrinking TT8 continues exactly while feasibility is violated, so TT9 is a longest feasible suffix ending at PP0.
  • Global Optimality: For any optimal substring PP1, when PP2 the algorithm’s window will include a feasible window of length at least PP3; the maximum seen is always retained.
  • Time and Space Complexity: Each of pointers PP4, PP5 is advanced at most PP6 times. Array initializations and per-symbol updates are PP7. Initialization over PP8 is PP9; total runtime is Σ\Sigma0. Space is Σ\Sigma1 for Σ\Sigma2, Σ\Sigma3, and auxiliary counters.

4. Step-by-Step Example

Given Σ\Sigma4 (Σ\Sigma5, Σ\Sigma6) and Σ\Sigma7 (Σ\Sigma8):

Σ\Sigma9 Added char σ\sigma0 change σ\sigma1 Window σ\sigma2 Remarks / σ\sigma3
0 'a' σ\sigma4 0 σ\sigma5 Set σ\sigma6
1 'b' σ\sigma7 0 σ\sigma8 Set σ\sigma9
2 'a' P∈ΣmP \in \Sigma^m0 0 P∈ΣmP \in \Sigma^m1 Set P∈ΣmP \in \Sigma^m2
3 'a' P∈ΣmP \in \Sigma^m3 1 shrink P∈ΣmP \in \Sigma^m4: P∈ΣmP \in \Sigma^m5, P∈ΣmP \in \Sigma^m6, resolve violation No update (tie)
4 'c' P∈ΣmP \in \Sigma^m7 1 shrink P∈ΣmP \in \Sigma^m8: P∈ΣmP \in \Sigma^m9, T∈ΣnT \in \Sigma^n0, resolve violation No update
5 'b' T∈ΣnT \in \Sigma^n1 0 T∈ΣnT \in \Sigma^n2 Set T∈ΣnT \in \Sigma^n3

The returned substring is T∈ΣnT \in \Sigma^n4 of length T∈ΣnT \in \Sigma^n5, conforming to the Parikh budget T∈ΣnT \in \Sigma^n6.

5. Specializations and Connections

  • Single-Symbol Cases: For T∈ΣnT \in \Sigma^n7 with a single symbol T∈ΣnT \in \Sigma^n8 at frequency T∈ΣnT \in \Sigma^n9, MFSP reduces to the classic search for the longest run of SS0 in SS1.
  • Alphabet Reduction: If SS2 is large but SS3 is small, the alphabet can be compressed to a smaller effective size SS4 prior to algorithm execution.
  • Permutation Matching and Packing: MFSP generalizes permutation matching, which asks whether some substring's Parikh vector exactly matches SS5; this variant is handled by maintaining a difference vector and can also be solved in SS6 time within this framework.
  • Non-overlapping Occurrences: After enumerating all length-SS7 matches, maximizing the count of disjoint occurrences reduces to the equal-length interval packing problem, solved by left-to-right greedy selection in SS8 time.

6. Generalizations and Further Directions

  • Approximate and Weighted Variants: MFSP admits relaxation to allow limited violation (e.g., SS9), or extension to weighted settings where each symbol is associated with a cost or value, yielding knapsack-like, resource-constrained substring optimization problems.
  • Relation to Sliding-Window and Packing Paradigms: MFSP demonstrates that frequency-based string matching admits precise resource-budget interpretations, connecting classic sliding-window substring search with packing-style optimization. This suggests a broader applicability in text algorithms and resource allocation frameworks (Shanto et al., 14 Jan 2026).

7. Summary

MFSP formalizes and solves, in optimal TT00 time and TT01 space, the problem of finding the longest substring under Parikh-component supply constraints. This sliding-window, two-pointer algorithm extends permutation matching, supports concise maximal-resource interpretations, and links string algorithms to combinatorial packing primitives (Shanto et al., 14 Jan 2026).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Maximum Feasible Substring under Pattern Supply (MFSP).