#135 Finding and Sorting Hashtags
Implement getTags and getTagsByPopularity:
public class Main {
public static void main(String[] args) {
List<String> text = List.of(
"Hello #Moscow",
"Hello #SaintPetersburg",
"#SaintPetersburg has good #Weather",
"#Moscow has bad #Weather",
"#Moscow has #Rain"
);
System.out.println(getTags(text));
System.out.println(getTagsByPopularity(text));
}
private static List<String> getTags(List<String> text) {
// collect all unique tags ignoring case and sort them alphabetically
return
}
private static List<String> getTagsByPopularity(List<String> text) {
// collect all unique tags ignoring case and sort them by popularity
return
}
}
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor