ar_rony1's blog

By ar_rony1, history, 3 weeks ago, In English

How can i solve following problem using string hashing? SUB_PROB

 
 
 
 
  • Vote: I like it
  • -1
  • Vote: I do not like it

»
3 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Use Rabin-Karp Algorithm. It uses string hashing.

  • »
    »
    3 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Ok thanks!

  • »
    »
    3 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Isn't the time limit too strict for Rabin-Karp?

    • »
      »
      »
      3 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Rabin-karp complexity is O(n*m) and this problem time limit is 0.100s. So what will be the better approach?

      • »
        »
        »
        »
        3 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I couldn't come up with anything using string hashing, but the problem might be solved using suffix array with complexity O(MlogM + N*logM). (still not sure if it's gonna pass since time limit is too tight) You can check it out here.