Document Open Access Logo

Computing longest common square subsequences

Authors Takafumi Inoue, Shunsuke Inenaga, Heikki Hyyrö, Hideo Bannai , Masayuki Takeda

Thumbnail PDF


  • Filesize: 0.59 MB
  • 13 pages

Document Identifiers

Author Details

Takafumi Inoue
  • Department of Informatics, Kyushu University, Japan
Shunsuke Inenaga
  • Department of Informatics, Kyushu University, Japan
Heikki Hyyrö
  • Faculty of Natural Sciences, University of Tampere, Finland
Hideo Bannai
  • Department of Informatics, Kyushu University, Japan
Masayuki Takeda
  • Department of Informatics, Kyushu University, Japan

Cite AsGet BibTex

Takafumi Inoue, Shunsuke Inenaga, Heikki Hyyrö, Hideo Bannai, and Masayuki Takeda. Computing longest common square subsequences. In 29th Annual Symposium on Combinatorial Pattern Matching (CPM 2018). Leibniz International Proceedings in Informatics (LIPIcs), Volume 105, pp. 15:1-15:13, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2018)


A square is a non-empty string of form YY. The longest common square subsequence (LCSqS) problem is to compute a longest square occurring as a subsequence in two given strings A and B. We show that the problem can easily be solved in O(n^6) time or O(|M|n^4) time with O(n^4) space, where n is the length of the strings and M is the set of matching points between A and B. Then, we show that the problem can also be solved in O(sigma |M|^3 + n) time and O(|M|^2 + n) space, or in O(|M|^3 log^2 n log log n + n) time with O(|M|^3 + n) space, where sigma is the number of distinct characters occurring in A and B. We also study lower bounds for the LCSqS problem for two or more strings.

Subject Classification

ACM Subject Classification
  • Mathematics of computing → Combinatorial algorithms
  • squares
  • subsequences
  • matching rectangles
  • dynamic programming


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Amir Abboud, Arturs Backurs, and Virginia Vassilevska Williams. Tight hardness results for LCS and other sequence similarity measures. In Proc. FOCS 2015, pages 59-78, 2015. Google Scholar
  2. Abdullah N. Arslan. Regular expression constrained sequence alignment. J. Disc. Algo., 5(4):647-661, 2007. Google Scholar
  3. Sang Won Bae and Inbok Lee. On finding a longest common palindromic subsequence. Theor. Comput. Sci., 710:29-34, 2018. Google Scholar
  4. Jon Louis Bentley and Jerome H. Friedman. Data structures for range searching. ACM Comput. Surv., 11(4):397-409, 1979. Google Scholar
  5. Philip Bille and Martin Farach-Colton. Fast and compact regular expression matching. Theor. Comput. Sci., 409(3):486-496, 2008. Google Scholar
  6. Karl Bringmann and Marvin Künnemann. Quadratic conditional lower bounds for string problems and dynamic time warping. In Proc. FOCS 2015, pages 79-97, 2015. Google Scholar
  7. Francis Y. L. Chin, Alfredo De Santis, Anna Lisa Ferrara, N. L. Ho, and S. K. Kim. A simple algorithm for the constrained sequence problems. Inf. Process. Lett., 90(4):175-179, 2004. Google Scholar
  8. Shihabur Rahman Chowdhury, Md. Mahbubul Hasan, Sumaiya Iqbal, and M. Sohel Rahman. Computing a longest common palindromic subsequence. Fundam. Inform., 129(4):329-340, 2014. Google Scholar
  9. Sebastian Deorowicz. Quadratic-time algorithm for a string constrained LCS problem. Inf. Process. Lett., 112(11):423-426, 2012. Google Scholar
  10. Effat Farhana and M. Sohel Rahman. Doubly-constrained LCS and hybrid-constrained LCS problems revisited. Inf. Process. Lett., 112(13):562-565, 2012. Google Scholar
  11. Effat Farhana and M. Sohel Rahman. Constrained sequence analysis algorithms in computational biology. Inf. Sci., 295:247-257, 2015. Google Scholar
  12. Szymon Grabowski. New tabulation and sparse dynamic programming based techniques for sequence similarity problems. Discrete Applied Mathematics, 212:96-103, 2016. Google Scholar
  13. Heikki Hyyrö, Kazuyuki Narisawa, and Shunsuke Inenaga. Dynamic edit distance table under a general weighted cost function. J. Disc. Algo., 34:2-17, 2015. Google Scholar
  14. Costas S. Iliopoulos and Mohammad Sohel Rahman. New efficient algorithms for the LCS and constrained LCS problems. Inf. Process. Lett., 106(1):13-18, 2008. Google Scholar
  15. Costas S. Iliopoulos and Mohammad Sohel Rahman. A new efficient algorithm for computing the longest common subsequence. Theory Comput. Syst., 45(2):355-371, 2009. Google Scholar
  16. Shunsuke Inenaga and Heikki Hyyrö. A hardness result and new algorithm for the longest common palindromic subsequence problem. Inf. Process. Lett., 129:11-15, 2018. Google Scholar
  17. Sung-Ryul Kim and Kunsoo Park. A dynamic edit distance table. J. Disc. Algo., 2:302-312, 2004. Google Scholar
  18. Adrian Kosowski. An efficient algorithm for the longest tandem scattered subsequence problem. In Proc. SPIRE 2004, pages 93-100, 2004. Google Scholar
  19. Keita Kuboi, Yuta Fujishige, Shunsuke Inenaga, Hideo Bannai, and Masayuki Takeda. Faster str-ic-lcs computation via rle. In Proc. CPM 2017, page 25:1–25:12, 2017. Google Scholar
  20. Gregory Kucherov, Tamar Pinhas, and Michal Ziv-Ukelson. Regular language constrained sequence alignment revisited. J. Computational Biology, 18(5):771-781, 2011. Google Scholar
  21. Gad M. Landau, Eugene W. Myers, and Jeanette P. Schmidt. Incremental string comparison. SIAM J. Comp., 27(2):557-582, 1998. Google Scholar
  22. William J. Masek and Mike Paterson. A faster algorithm computing string edit distances. J. Comput. Syst. Sci., 20(1):18-31, 1980. Google Scholar
  23. Yoshifumi Sakai. An almost quadratic time algorithm for sparse spliced alignment. Theory Comput. Syst., 48(1):189-210, 2011. Google Scholar
  24. Jeanette P. Schmidt. All highest scoring paths in weighted grid graphs and their application in finding all approximate repeats in strings. SIAM J. Comp., 27(4):972-992, 1998. Google Scholar
  25. Alexandre Tiskin. Semi-local string comparison: algorithmic techniques and applications. CoRR, abs/0707.3619, 2007. URL:
  26. Peter van Emde Boas. Preserving order in a forest in less than logarithmic time. In Proc. FOCS 1975, pages 75-84, 1975. Google Scholar
  27. Robert A. Wagner and Michael J. Fischer. The string-to-string correction problem. J. ACM, 21(1):168-173, 1974. Google Scholar
  28. Daxin Zhu and Xiaodong Wang. A simple algorithm for solving for the generalized longest common subsequence (LCS) problem with a substring exclusion constraint. Algorithms, 6(3):485-493, 2013. Google Scholar
  29. Daxin Zhu, Yingjie Wu, and Xiaodong Wang. An efficient algorithm for a new constrained LCS problem. In Proc. ACIIDS 2016, pages 261-267, 2016. Google Scholar
  30. Daxin Zhu, Yingjie Wu, and Xiaodong Wang. An efficient dynamic programming algorithm for STR-IC-STR-EC-LCS problem. In Proc. GPC 2016, pages 3-17, 2016. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail