My python solution


#1

def repeatedNumber(self, A):
    counts = {}
    for e in A:
          if e not in counts:
                counts[e] = 1
          else:
                counts[e] += 1
          if (counts[e]) > (len(A) / 3):
                return e
    else:
          return -1


#2

Your counts dictionary may use up to O(n) additional space, i.e. not O(1) space.