title: How the time complexity O(n) is calculated?
body: <p>Lets assume the following code (Python)- Leader in the array</p>
  
  <pre><code>def goldenLeader(A):
      n = len(A)
      size=0
      for k in xrange(n):
         if (size == 0): size += 1
            value = A[k] else:
         if (value != A[k]): size -= 1
         else:
           size += 1
      candidate = -1 if (size &gt; 0):
      candidate = value leader = -1
      count = 0
      for k in xrange(n):
          if (A[k] == candidate): count += 1
      if(count&gt;n//2): leader = candidate
      return leader
  </code></pre>
  
  <p>So Since we are  traversing the array A twice ,the time complexity should be O(n + n)</p>
  
  <p>But it is mentioned the time complexity to be O(n)</p>
  
  <p>How come?</p>