Why different values return when press run and submit


  • 0
    C

    I have met something really strange, when I ran this code, it seems that it's all ok, but when I press submit, it always fails at this case:

    char* s = "xpmssbwloowxibtwvhabflaoqgoyswznxepaoevvqohhamkucbcfsonazfnmcoqechnyigsbuvzrligprykurwahetwjmdknmearurflryhligaptsdqrlgapoyzocwwnavcsdiuqpbzmedzsvifcqzjjqqjshqmxczobymhwwiojfcvfjvaygupgacyvhnckmdasgspxoijltxebfspwlpjbzpoonalwujttowlsiagmcgfqwxoznuehztvuvpgzrvrjnybfcolufwgwsgmuxdqfgcisxgeibinqxacrtwznwvmxximhhhdehxrftpcczubiabgkbscrundidaqzcbmzpiqecfruiffzuajxjnnwipeivtswffizywisuvhkkcjwgxazntusebfbaawflsazleudgmhyzgfspyqmqanozvksrougiypcmiokgdhmkwyngmrynkekfjogjpgannxdtczvgxmatirlfcsphzouosyknxigetrpzudjaxcepvdfmqfyjpvxifntszpbzfkrlxgodjecpvtljolottyhaonpvatwhynicfusbrcnfhkpglaouhmljaavvguoiyiynpqykhaqsbbdroszpawpzgjtnzmqeiuvbwhyphrhqzbaqnnusbiopkzbsovqtykfioyurtqqnspkhnllmsvkgewpslshrambdokxhrelsehvvgitcwyrhivarxjagtsgfnhudizcbmvncgjfa"
    char* t = "wsxqlutrifhyejgmohyvlkjobelupizpgbgavnltzspgvmthdhioonnilqshpsvyejddnitnxrpmdvkudqhoajzupcxrwghhyhudsqrszojzwpcbontwdbfbqncysqzgoayjxbqkieamizzsoaqksqwjmjawwmkltcfzffruhaarhcexhenrgizwvnqfkrfhthbovxuynxoltrtagsceiiphsombaqcztfookpepwymnsxtlspgbdkmyezlzdvinemwibvsggnyfoabsfqxtgzecfiwpyqzsiilnrmugnbczsouczgfmkhunqfhpzqgyurrzpqccmvfjnbwgwrlclnvvsgbhkdfipnsinmasvryegdzuiazoisrcbgpyohvhvpujjxxtoruxpomxmjwuockcwjgpnhlfojvapaxnablqhujdtsofuiapfcjcdvxsavkavmrptqptpnxaasazuolwcltbysmezytwvmzislbasghogaqhhjqryzmbubsewcyustwguyiyvgswcefbpgrzjgvwezzmzfatatksonevbcupwtoxcjxaivqxciuklycbacoonuvvmuaazmrgguiuzyrhjbipwjpurofecklonpldgofikgijfiknaqisrmxfnvlqbwwifykjogtdqocdpffetagavwrchfiskwwecmrhhnpvlifaxkhbdapyafighonnxeamgpqnazvsnkbzrdcwyfyssseagfhlixn"
    

    But when I tested the case using RUN BUTTON, it became all OK. Can somebody help me figure this out? Thank you.

    Here is my code in C:

    char findTheDifference(char* s, char* t) {
        size_t i;
        int* hash_table = (int*)malloc(26*sizeof(int));
        memset(hash_table,0,26);
        for(;*t != '\0';hash_table[*t++ - 'a']++);
        for(;*s != '\0';hash_table[*s++ - 'a']--);
        for (i = 0; i < 26; i++){
            if (hash_table[i] == 1) return (char)('a' + i);
        }
        return NULL;
    }
    

Log in to reply
 

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