arXiv:2611.05725cs.DSNov 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2611.05725

Faster Approximate Text-to-Pattern Hamming Distances via Near-Optimal Sumset Estimation

Nick Fischer, Yael Kirkpatrick, Vasileios Nakos

Abstract

Text-to-Pattern Hamming Distances is one of the most studied problems in string algorithms: given a text TT of length nn and a pattern PP, the task is to compute the Hamming distance between PP and every length-∣P∣|P| substring of TT. As exact algorithms have been stuck at time O~(n3/2)\tilde{O}(n^{3/2}) for decades, a long line of work has turned to the (1+ϵ)(1+\epsilon)-approximate version of the problem. Milestones include Karloff's O~(ϵ−2n)\tilde{O}(\epsilon^{-2}n)-time algorithm [IPL '93], followed by randomized improvements to O~(ϵ−1n)\tilde{O}(\epsilon^{-1}n) by Kopelowitz and Porat [FOCS '15] and recently to O~(ϵ−0.915n)\tilde{O}(\epsilon^{-0.915}n) by Chan, Jin, Vassilevska W., and Xu [FOCS '23].

In this work, we significantly improve this bound to O~(ϵ−2/3n)\tilde{O}(\epsilon^{-2/3}n), using a considerably simpler algorithm. Our algorithm follows the framework of Chan, Jin, Vassilevska W., and Xu, which reduces the problem to a variant of 3SUM that we call Sumset Estimation. We solve Sumset Estimation optimally (up to logarithmic factors) by replacing their matrix multiplication techniques with ideas from sparse recovery. Specifically, we adapt the classic Count Sketch by replacing its random signs with random complex roots of unity—a simple idea that may find further applications for other additive problems.

Finally, we give evidence that our running time might in fact be optimal: we show that the ϵ−2/3\epsilon^{-2/3} dependence is best possible for a certain natural class of algorithms, including ours and all previous algorithms.

Contents

1 Introduction 1
1.1 Our Improvement ..... 2
2 Preliminaries 3
3 Technical Overview 3
3.1 The Chan-Jin-Vassilevska W.-Xu Algorithm ..... 3
3.2 Our Improvement: A Near-Optimal Algorithm for Sumset Estimation ..... 5
4 Near-Optimal Sumset Estimation 8
4.1 Estimating Heavy Hitters ..... 8
4.1.1 Good Elements and Running Time ..... 9
4.1.2 Correctness Analysis ..... 10
4.1.3 Computing with Complex Numbers ..... 12
4.2 Estimating Sumsets ..... 12
4.3 Estimating Sumsets of Aligned Intervals ..... 14
5 Approximate Text-to-Pattern Hamming Distances 15
6 Matching Lower Bound for a Restricted Class of Algorithms 17
A Reducing Bounded Distance to Short Run-Length Encoding 22

References (37)