Skip to content

Bug Report for anagram-groups - Internal Delimiter showing in 'Your Output' #5790

@Norky101

Description

@Norky101

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.

I was experimenting with a solution and noticed this as 'Your Output.' This seems to be a :

Your Output:
===USE_THIS_LINE_TO_SEPARATE_USER_LOGS_AND_TEST_CASE_OUTPUT_394w8389wry89areisJAHSDBHJBdsjnkzbdcifbscidfbasekhfgiJHBG===

Full code from window:

`class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
# what does the Q want?

     # return all anagrams into sublists - any order

     # anagrams - same chars as another string + same freq of chars

     # edges
    if len(strs) == 1: 
        return [strs]
    if not strs:  
        return [strs]
    
    # steps
    # dict key=sorted string : [value=original string]
        # - sort the input list
        # add to dict

    # create empty dict
    # loop over the input list 
    # check if curr sorted string is in dict: 
        # yes - add to the values list in unsorted form
    
    # No- add sorted curr string to key & unsorted curr string to val 

    # end - loop over the dict values and add them to a list - return that list

    # challenge - sort the list, whilst also retaining original string
        # A - Tuple

    #strs.sort() # inplace 
    char_dict = {}

    for string in strs: 
        sorted_characters = sorted(string) # list
        sorted_string = "".join(sorted_characters)
        #print(sorted_string)

        if sorted_string not in char_dict: 
            char_dict[sorted_string[0]] = [string]
        
        else: 
            char_dict[sorted_string].append(string)
        
    return [ [v] for v in char_dict.values()]`

Test cases

Default test cases were used:

Input: strs = ["act","pots","tops","cat","stop","hat"]

Output: [["hat"],["act", "cat"],["stop", "pots", "tops"]]

Input: strs = ["x"]

Output: [["x"]]

I put this into AI to help diagnose

The separator string is a neetcode platform leak

===USE_THIS_LINE_TO_SEPARATE_USER_LOGS_AND_TEST_CASE_OUTPUT...=== is an internal delimiter their judge uses to split your print() logs from the actual return value

It shouldn't be visible in "Your Output."
Likely triggered when your function returns something that fails to serialize cleanly, or when stdout/stderr ordering gets weird

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