Question: Write a Java program which takes in an int n , followed by a list of n English words. The program should sort the list

Write a Java program which takes in an int n, followed
by a list of n English words. The program should sort
the list of Strings according to how many unique
characters they contain. If two Strings contain the same
number of unique characters, then they should be
sorted alphabetically. The program should print out the
sorted list, with words containing the fewest number of
unique characters coming first.
Sample input
tree
paper
car
banana
Sample output
banana
car
tree
paper

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!