#135 Finding and Sorting Hashtags

Companies:
Sberbank
Themes:
JavaStreams & LambdasStringsHash TablesPractice

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

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in