title: Largest substring composed of identical characters
body: <p>I want to develop method that will return the length of largest substring composed of identical characters form string that is passed as argument, but without using any of <code>.NET libraries</code>.</p>
  
  <p>For example if we pass <code>aaacccccdefffgg</code> as parameter the biggest substring is <code>ccccc</code> and method should return 5.</p>
  
  <p>Here is my working solution :</p>
  
  <pre><code>public static int GetMaxSubstringLenght(char[] myArray)
      {
          int max = 0;
  
          for (int i = 0; i &lt; myArray.Length-1; i++)
          {
              if (myArray.Length == 0)
              {
                  return 0;
              }
              else
              {
                  int j = i + 1;
                  int currentMax = 1; // string has some value, so we start with 1
                  while (myArray[i] == myArray[j])
                  {
                      currentMax++;
                      if (max &lt; currentMax)
                      {
                          max = currentMax;
                      }
                      j++;
                  }
              }                
          }
          return max;
      }
  </code></pre>
  
  <p>The code above will return expected result, but there will be some unnecessary iteration in <code>for loop</code> that I want to avoid. In first iteration when <code>i=0</code>it will compare it until <code>j=2</code> and then will get out of <code>while loop</code> and start second iteration in <code>for loop</code> comparing the one at <code>[1]</code> index with <code>[2]</code>, which we already did in previous iteration.So basically, when first iteration is completed, next one should start from the last value of <code>j</code>. How can I achieve that ?</p>
  
  <p>Thank You in advance.</p>