Someone please tell me why this solution is not O(N)

class Solution:

# @param A : list of integers

# @param B : integer

# @return an integer

def diffPossible(self, A, B):

j=len(A)

if B==0:

for i in range(len(A)-1):

if A[i]==A[i+1]:

return 1

return 0

for i in range(len(A)):

if A[i]+B in A:

return 1

return 0

[/quote]

# Why this is not O(N)

**rishab178**#2

How do you think is this line getting evaluated internally?

`if A[i]+B in A:`

This line in itself is an O(N) operation and you are iterating over this N times.

Your algorithm thus is O(N^2)