Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def binarySearch(list, low, high, n):
- i = 0
- while (low <= high):
- i = (high + low) // 2
- if (list[i] == n):
- return 1
- if (list[i] < n):
- low = i + 1
- else:
- high = i - 1
- return 0
- def checkTwoSum(list, arr_size, sum):
- list.sort()
- lenght = arr_size - 1
- for i in range(0,lenght):
- searchKey = sum - list[i]
- if (binarySearch(list, i + 1, lenght, searchKey) == 1):
- return 1
- return 0
- def print_result(A: list , n: int):
- if (checkTwoSum(A, len(A), n)):
- print("Yes")
- else:
- print("No")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement