How do I find hash of any sub-string in O(1) by O(n) preprocessing.

Revision en1, by ayushmishra.iit, 2015-06-08 11:16:45

I have a string of length n. I could have queries like query(i, j) which should return the hash of the sub-string starting at i and ending at j inclusive. This query should be answered in O(1). And a preprocessing of o(n) or o(n log n) is allowed initially.

Can anyone give me idea how to do such thing?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English ayushmishra.iit 2015-06-08 11:16:45 375 Initial revision (published)