"Run code" and "Submit" yield different result giving the same test


  • 0
    H

    First of all here is the picture as evidence:
    0_1490261452143_Screen Shot 2017-03-23 at 5.13.49 PM.png
    Then code as follows:

    int map[255]={0};
    int lengthOfLongestSubstring(char* s) {
    int i,j,max=0,tmp;
       if (strlen(s) == 0){
           return 0;
       }
       i = 0;
       map[s[i]]=i+1;
       for (j=1;j<strlen(s);j++){
           if (map[s[j]]!=0){
               if ((j-i)>max){
                   max=j-i;
               }
               tmp=i;
               i=map[s[j]];
               for (;tmp<i-1;tmp++){
                   map[s[tmp]]=0;
               }
               map[s[j]]=j+1;
           }else{
               map[s[j]]=j+1;
           }
       }
       if ((j-i)>max){
            max=j-i;
       } 
        return max;
    }

  • 0

    Follow the instructions that are shown in your screenshot.


  • 0
    H

    @StefanPochmann Thanks for replying, and please define "instructions" because I don't see any in the screenshots.


  • 0
    H

    @StefanPochmann Sorry just now I discovered the instructions...Ignore my last message.


Log in to reply
 

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