Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ariestiyansyah/8452832 to your computer and use it in GitHub Desktop.
Save ariestiyansyah/8452832 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
A = [1, 8, -3, 0, 1, 3, -2, 4, 5]
def solution(K, A):
contenga = {}
for x in A:
if x not in contenga:
contenga[x] = 0
contenga[x] += 1
N = 0
for i in contenga:
N += contenga[i] * contenga.get(K-i, 0)
return N
print solution(6, A)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment