Bug - contains() returns true without check

contains() method, which checks whether a word is present in the DAWG,
returns true without checking whether a valid word ends at that index.
Alternatively, it returns true when the input is a prefix of some word
in the dictionary, false otherwise.

As per the discussion on the accepted answer here - http://stackoverflow.com/questions/18963783/build-trie-faster