It could be improved by using primitives (char, int) alternatively to their Object version (Character, Integer) to the expense of losing the low complexity in terms of readability since using primitives requires developing dedicated data structures or working with array of arrays of primitives and along with proofing isomorphism implement the charterscharacters look up into the arrays.