Skip to content

Bug Report for anagram-groups #4784

@YogeshTewani

Description

@YogeshTewani

Bug Report for https://neetcode.io/problems/anagram-groups

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

Trying to complie java code on the tool but fails with 'Illegal Start Of Type' error

import java.util.*;

class Solution {
    public List<List<String>> groupAnagrams(String[] strs) {
       Map<String, List<String>> res = new HashMap<>();

        for (String str: strs) {
            int[] count = new int[26];

            for(char c : str.toCharArray()) {
                count[c - 'a'] += 1;
            }
            String key = "";
            for (int i : count) {
                key += i + "#";
            }

            res.putIfAbsent(key, new ArrayList<>());
            res.get(key).add(str);
        } 
        return new ArrayList<>(res.values());    
    }
}

Error

Main.java:1: error: illegal start of type
    import java.util.*;
    ^
Main.java:1: error: <identifier> expected
    import java.util.*;
                     ^
2 errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions