Faster STR-EC-LCS Computation

  • Kohei YamadaEmail author
  • Yuto Nakashima
  • Shunsuke Inenaga
  • Hideo Bannai
  • Masayuki Takeda
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 12011)


The longest common subsequence (LCS) problem is a central problem in stringology that finds the longest common subsequence of given two strings A and B. More recently, a set of four constrained LCS problems (called generalized constrained LCS problem) were proposed by Chen and Chao [J. Comb. Optim, 2011]. In this paper, we consider the substring-excluding constrained LCS (STR-EC-LCS) problem. A string Z is said to be an STR-EC-LCS of two given strings A and B excluding P if, Z is one of the longest common subsequences of A and B that does not contain P as a substring. Wang et al. proposed a dynamic programming solution which computes an STR-EC-LCS in O(mnr) time and space where \(m = |A|, n = |B|, r = |P|\) [Inf. Process. Lett., 2013]. In this paper, we show a new solution for the STR-EC-LCS problem. Our algorithm computes an STR-EC-LCS in \(O(n|\varSigma | + (L+1)(m-L+1)r)\) time where \(|\varSigma | \le \min \{m, n\}\) denotes the set of distinct characters occurring in both A and B, and L is the length of the STR-EC-LCS. This algorithm is faster than the O(mnr)-time algorithm for short/long STR-EC-LCS (namely, \(L \in O(1)\) or \(m-L \in O(1)\)), and is at least as efficient as the O(mnr)-time algorithm for all cases.



This work was supported by JSPS KAKENHI Grant Numbers JP18K18002 (YN), JP17H01697 (SI), JP16H02783 (HB), JP18H04098 (MT), and by JST PRESTO Grant Number JPMJPR1922 (SI).


  1. 1.
    Abboud, A., Backurs, A., Williams, V.V.: Tight hardness results for LCS and other sequence similarity measures. FOCS 2015, 59–78 (2015)MathSciNetGoogle Scholar
  2. 2.
    Ahsan, S.B., Aziz, S.P., Rahman, M.S.: Longest common subsequence problem for run-length-encoded strings. In: 2012 15th International Conference on Computer and Information Technology (ICCIT), pp. 36–41, December 2012Google Scholar
  3. 3.
    Bunke, H., Csirik, J.: An improved algorithm for computing the edit distance of run-length coded strings. Inf. Process. Lett. 54(2), 93–96 (1995). CrossRefGoogle Scholar
  4. 4.
    Chen, Y.C., Chao, K.M.: On the generalized constrained longest common subsequence problems. J. Comb. Optim. 21(3), 383–392 (2011). Scholar
  5. 5.
    Chin, F.Y., Santis, A.D., Ferrara, A.L., Ho, N., Kim, S.: A simple algorithm for the constrained sequence problems. Inf. Process. Lett. 90(4), 175–179 (2004). Scholar
  6. 6.
    Deorowicz, S.: Quadratic-time algorithm for a string constrained lcs problem. Inf. Process. Lett. 112(11), 423–426 (2012). Scholar
  7. 7.
    Inenaga, S., Hyyrö, H.: A hardness result and new algorithm for the longest common palindromic subsequence problem. Inf. Process. Lett. 129, 11–15 (2018)MathSciNetCrossRefGoogle Scholar
  8. 8.
    Kuboi, K., Fujishige, Y., Inenaga, S., Bannai, H., Takeda, M.: Faster STR-IC-LCS computation via RLE. In: Kärkkäinen, J., Radoszewski, J., Rytter, W. (eds.) 28th Annual Symposium on Combinatorial Pattern Matching, CPM 2017, 4–6 July 2017, Warsaw, Poland. LIPIcs, vol. 78, pp. 20:1–20:12. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik (2017).
  9. 9.
    Liu, J.J., Wang, Y.L., Chiu, Y.S.: Constrained longest common subsequences with run-length-encoded strings. Comput. J. 58(5), 1074–1084 (2014). Scholar
  10. 10.
    Nakatsu, N., Kambayashi, Y., Yajima, S.: A longest common subsequence algorithm suitable for similar text strings. Acta Inf. 18, 171–179 (1982). Scholar
  11. 11.
    Stern, H., Shmueli, M., Berman, S.: Most discriminating segment - longest common subsequence (MDSLCS) algorithm for dynamic hand gesture classification. Pattern Recogn. Lett. 34(15), 1980–1989 (2013)., smart Approaches for Human Action RecognitionCrossRefGoogle Scholar
  12. 12.
    Tsai, Y.T.: The constrained longest common subsequence problem. Inf. Process. Lett. 88(4), 173–176 (2003). Scholar
  13. 13.
    Wagner, R.A., Fischer, M.J.: The string-to-string correction problem. J. ACM 21(1), 168–173 (1974). Scholar
  14. 14.
    Wang, C., Zhang, D.: A novel compression tool for efficient storage of genome resequencing data. Nucleic Acids Res. 39(7), e45 (2011). Scholar
  15. 15.
    Wang, L., Wang, X., Wu, Y., Zhu, D.: A dynamic programming solution to a generalized LCS problem. Inf. Process. Lett. 113(19–21), 723–728 (2013). Scholar

Copyright information

© Springer Nature Switzerland AG 2020

Authors and Affiliations

  • Kohei Yamada
    • 1
    Email author
  • Yuto Nakashima
    • 1
  • Shunsuke Inenaga
    • 1
    • 2
  • Hideo Bannai
    • 1
  • Masayuki Takeda
    • 1
  1. 1.Department of InformaticsKyushu UniversityFukuokaJapan
  2. 2.PRESTO, Japan Science and Technology AgencyKawaguchiJapan

Personalised recommendations