title: max consecutive 1 or 0 that can be obtained by flipping one bit of binary nubmer
body: <p>given a binary number find the maximum consecutive 1s or 0s that can be obtained by flipping only one bit (either a 1 or a 0) </p>
  
  <p>the code given was </p>
  
  <pre><code>    public int getMacCon(string[] A)
      {
          int n = A.Length;
          int result = 0;
          for (int i = 0; i &lt; n - 1; i++)
          {
              if (A[i] == A[i + 1])
                  result = result + 1;
          }
          int r = -2;
  
          for (int i = 0; i &lt; n; i++)
          {
              int count = 0;
              if (i &gt; 0)
              {
                  if (A[i - 1] != A[i])
                      count = count + 1;
                  else
                      count = count - 1;
              }
              if (i &lt; n - 1)
              {
                  if (A[i + 1] != A[i])
                      count = count + 1;
                  else
                      count = count - 1;
              }
              r = Math.Max(r, count);
          }
          return result + r;
      }
  </code></pre>
  
  <p>Im finding hard to figure out the logic here. specially the given below part</p>
  
  <pre><code>    for (int i = 0; i &lt; n - 1; i++)
      {
          if (A[i] == A[i + 1])
              result = result + 1;
      }
  </code></pre>
  
  <p>I would highly apretiate if any one can explain me the logic in this solution.
  Thanks</p>