1

If you want to count the letters in a word there's no need for the alphabet array and the nested loops. Java chars are an integer type, and the letters a-z are consecutive in UniCode, so all you need is

for (char c : word.toCharArray())  count[c - 'a']++;
Votes + Comments
nice point
1

^^ All the above is correct. Again, you have to look at this objectively. You could have used my algorithm but you would have obtained NO points because you haven't used datastructures.

So perhaps it is a moot point. I'm pretty sure your teacher isn't probably aware of this elegant solution otherwise everyone would have turned it in.

In education, these things hardly matter. What matters is if you've used the techniques taught on the course. It doesn't even matter if your code works. What matters is if you have written clear, and organised code. As far as I'm concerned, you've ticked all those boxes so you can expect your A grade.

Of course, when you get into the real world these things matter. All this is learned from experience. Like you I began with a similar permute algorithm. It was only through lots of trial and error and googling that I discovered this elegant solution.

Votes + Comments
Thank you for the encouragement :) Actually everyone had to choose a different project idea for themselves :P
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.