With respect to simply speeding the code up (don't have time right now to read the full problem): but you can speed it up a bit by using Set instead of ArrayList for dictList. How much it speeds it...