Output:"e" Expected:'e'


  • 10
    Z

    What is wrong with leetcode judging system?
    No matter what language I try, it always says:
    --> Output:"e" Expected:'e'
    Aren't them the same :| ?


  • 1
    F

    I'm having the same problem...

    class Solution(object):
        def findTheDifference(self, s, t):
            result = 0
            for char in s:
                result ^= ord(char)
            for char in t:
                result ^= ord(char)
            return chr(result)
    

    Output: "e"
    Expected: 'e'

    When I modify the code to literally just return 'e' it still says the same thing. I think this is just a bug.


  • 0
    F

    This is frustrating. Someone needs to fix the test cases here because this question is completely broken.


  • 0
    R

    '''class Solution {
    public:
    char findTheDifference(string s, string t) {
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    int m=t.length();
    for(int i=0;i<m;i++)
    {
    if(s[i]!=t[i])
    return t[i];
    }
    }
    };'''

    I am having the same error:

    Input:
    "abcd"
    "abcde"
    Output:
    "e"
    Expected:
    'e'

    Kindly advise what is to be done.


  • 0
    B

    the same too.


  • 0
    J

    Same here, changing the language to Python 3 fixed it for me

    from collections import Counter
    
    class Solution(object):
        def findTheDifference(self, s, t):
            return list((Counter(t) - Counter(s)).keys())[0]
    

  • 0
    R

    The same question when i use c++, if i changed to c, it can pass.


  • 0
    J

    the same too


  • 0
    M

    same issue :(


Log in to reply
 

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