Task 5 of 5 · 0 solved · 5 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

Problem

10.3 Ordered collections — capstone: sorted word report

Read a count and then that many words. Print, in this order:

  • the distinct words as a sorted set, e.g. [apple, fig, pear]
  • one line per word — the word, a space, how many times it appeared — in alphabetical order
  • the alphabetically first and last word on one line

For 5 then pear apple pear fig apple:

[apple, fig, pear]
apple 2
fig 1
pear 2
apple pear

Use TreeMap and TreeSet: with the Hash versions the order would not be guaranteed and the output would be unpredictable.

time 1000 ms memory 256 Mb
Solution
Attempts: 0 A hint guides you to the fix — it never writes the code for you.
✦
Ready to check

Press «Submit» to run your code against the task's test cases — that is what sets your score. «AI review» is an optional second opinion: it reads your code — logic and style, not just the output — and suggests the next step without handing over the answer. It never changes your score.

Next module →
Working…