提出线性时间的排列模式匹配与资源打包算法,解决文本中符号频率约束下的最长子串查找。
Permutation Matching Under Parikh Budgets: Linear-Time Detection, Packing, and Disjoint Selection
- 通过维护帕里克向量差值,实现线性时间排列匹配检测。
- 在σ个字符下,可在O(n + σ)时间内求解最长符号受限子串。
- 适用于需要非重叠匹配的场景,如生物序列分析或资源分配问题。
研究在一般字母表Σ上的排列(混序/阿贝尔)模式匹配问题。给定长度为m的模式P和长度为n的文本T,经典任务是判断T中是否存在长度为m的子串,其帕里克向量等于P。虽然存在线性时间滑动窗口解法,但实际应用常需优化与打包变体。本文提出统一滑动窗口框架,通过维护P与当前窗口的帕里克向量差,实现O(n + σ)时间、O(σ)空间的排列匹配。在此基础上,提出最大可行子串问题(MFSP):寻找T中最长的子串S,其每个字符的出现次数不超过P对应值。证明可通过双指针可行性维护在O(n + σ)时间内求解,将模式视为资源预算。最后,将每个排列匹配建模为等长区间,证明贪心最早结束策略可获得最大不重叠匹配集,一旦匹配枚举完成,即可在线性时间内求解。结果提供紧致、正确且高效的算法,连接频率匹配与打包优化。
原文摘要 · Abstract (English)
We study permutation (jumbled/Abelian) pattern matching over a general alphabet $Σ$. Given a pattern P of length m and a text T of length n, the classical task is to decide whether T contains a length-m substring whose Parikh vector equals that of P . While this existence problem admits a linear-time sliding-window solution, many practical applications require optimization and packing variants beyond mere detection. We present a unified sliding-window framework based on maintaining the Parikh-vector difference between P and the current window of T , enabling permutation matching in O(n + σ) time and O(σ) space, where σ = |Σ|. Building on this foundation, we introduce a combinatorial-optimization variant that we call Maximum Feasible Substring under Pattern Supply (MFSP): find the longest substring S of T whose symbol counts are component-wise bounded by those of P . We show that MFSP can also be solved in O(n + σ) time via a two-pointer feasibility maintenance algorithm, providing an exact packing interpretation of P as a resource budget. Finally, we address non-overlapping occurrence selection by modeling each permutation match as an equal-length interval and proving that a greedy earliest-finishing strategy yields a maximum-cardinality set of disjoint matches, computable in linear time once all matches are enumerated. Our results provide concise, provably correct algorithms with tight bounds, and connect frequency-based string matching to packing-style optimization primitives.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。