Understanding String Hashing: A Beginner's Guide to Efficient String Comparison
Consider the following problem:
Given a string "hello", how would you represent it as a numerical value?
A straightforward approach would be to convert each character to its ASCII value and combine these numbers in some way. For "hello", this might look like 104, 101, 108, 108, 111. But how do we combine these into a singl ...
Posted on Tue, 15 Sep 2026 16:55:10 +0000 by mmoore
Algorithmic Solutions for Programming Contest Problems
Given an integer, determine if it is a palindrome.
The straightforward apprroach is to treat the input as a string and check if it reads the same forwards and backwards, which can be done in O(n) time where n is the length of the string.
A more efficient approach uses polynomial hashing with O(n) time complexity. We'll implement both forward an ...
Posted on Sun, 02 Aug 2026 16:19:16 +0000 by briglia23
Avoiding Negative Hash Codes from Java's String.hashCode() in Sharding Scenarios
When sharding data by a non-integer primary key or a composite key (usually concatenated in to a string), developers often rely on Java's built-in String.hashCode() method to derive a hash value, which is then used for modulo-based sharding. While convenient, this approach can produce negative hash codes, leading to invalid shard numbers. Under ...
Posted on Tue, 19 May 2026 15:09:12 +0000 by brianbehrens