No homework

Please don’t ask us to do your homework. Really. If it’s a question that’s generally appropriate for Java, that’s fine, but in general, homework problems are manufactured, with artificial limits, and asking us to comply with those limitations is ridiculous.
An example of a ridiculous limitation is: “I am not allowed to use HashMap.”
We’re real programmers, and we actually use Java. It’s one thing if your data structure is such that HashMap isn’t appropriate; who knows, maybe we know of an implementation of a Trie that may be useful.
With that said, we’re likely to recommend you use a library to do things; if that’s not appropriate for your situation, well, that’s not actually our problem.
So keep your homework to yourself; earn your own grade.