I think one of the classic ones for strings is called the Rabin-Karp algorithm. And it's simply the same idea that you have a mapping from your import into a set of integers.
我认为字符串哈希,最经典的是Rabin-Karp算法,它只是简单的相同概念,你有一个映射关系将你的输入映射成一组数字。
So just to show you how big a difference it makes, let's run a couple of numbers.
让我们试试一组数字吧,如果n是1000的话。
You can either think of it as an arrow and imagine the arrow, or you can reduce it to a pair of numbers, x and y.
你既可以用有向线段来表示,也可以用一组数字来表示,x 和 y
If you give me a pair of numbers, Ax and Ay, that's as good as giving me this arrow, because I can find the length of the arrow by Pythagoras' theorem.
如果给我一组数字,Ax 和 Ay,就相当于给了我这个箭头示意图,因为我可以利用毕达哥拉斯定理定理求出模长
应用推荐