Why does my code run differently locally and on Web pages?


  • 0
    T

    My Question is 49. Group Anagrams
    This is my code

    class Solution(object):
        def groupAnagrams(self, strs):
            c = {}
            for i in strs:
                temp = i
                a = set(i)
                b = ''.join(list(a))
                if b not in c:
                    c[b] = []
                c[b].append(i)        
            d = []
            for key in c:
                d.append(c[key])
            return d
    

    the example:

    ["cab","pug","pei","nay","ron","rae","ems","ida","mes"]
    

    On my computer, the answer is right:

    [["rae"], ["ida"], ["ems", "mes"], ["cab"], ["pei"], ["ron"], ["pug"], ["nay"]]  
    

    but in the web page, the output is:

    [["cab"],["nay"],["ron"],["pei"],["ida"],["pug"],["rae"],["ems"],["mes"]]
    

    Why does my code run differently locally and on Web pages?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.