zoukankan      html  css  js  c++  java
  • LCS problem using Binary-SearchRolling hash

    One TopCoder article introduces a very interesting alternative solution to Longest Common Sequences problem.

    It is based on this statement (http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=stringSearching):

    The important point that allows us to use BS is the fact that if the given strings have a common substring of length n, they also have at least one common substring of any length m < n. And if the two strings do not have a common substring of length n they do not have a common substring of any length m > n

    So we can start b-search on string length of s1, for s2, since current substr len is fixed, we use rolling-hash to check match. Also, another interesting point to handle collision in a typical BK algorithm: we use double hashing to avoid collision, instead of a O(n) brutal-force string comp mentioned in EPI-300.

  • 相关阅读:
    完全背包和多重背包的混合 F
    多重背包转化成完全背包 E
    I
    D. Beautiful Array DP
    B. Long Path dp
    C. Barcode dp
    dp D. Caesar's Legions
    docker-mysql
    日志级别facility
    实时同步lsyncd
  • 原文地址:https://www.cnblogs.com/tonix/p/4175075.html
Copyright © 2011-2022 走看看