title: Runtime Error Message: Line 17: index -3 out of bounds for type 'int [256]'
body: <p>I need help to understand an issue with my C code. I am trying to find longest substring within a given string without character repetition. When run on the leetcode platform, the code below gives me an error for the String <code>"amqpcsrumjjufpu"</code>:</p>
  
  <blockquote>
    <p>Runtime Error Message: Line 17: index -3 out of bounds for type 'int [256]' </p>
  </blockquote>
  
  <p>However, the same code works fine when I run it from my computer or any online editor. Please help me to understand this behaviour difference. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int lengthOfLongestSubstring(char* s) {
      char *h = s;
      int A[256] = {0};
      int length = 0;
      int temp = 0;
      int max = 0;
  
      int len = strlen(s);
  
      for(int i = 0; i &lt; len;i ++){
          int A[256] = {0};
          length = 0;
          h = s + i;
          for(int j = i; j &lt; len-1; j++){
  
              if (A[h[j]] == 1) {
                  break;
              } else {
                  A[h[j]] = 1;
                  length +=1;
              }
  
              if (max &lt; length) {
                  max = length;
              }                
          }
      }
  
      return max;
  }
  
  
  int main() {        
      char *s = "amqpcsrumjjufpu";
      int ret = lengthOfLongestSubstring(s);
      printf("SAURABH: %d",ret);
  }
  </code></pre>