Skip to content

Commit

Permalink
Merge pull request #13 from tankman03/patch-4
Browse files Browse the repository at this point in the history
Create CountPairsGivenSum.py
  • Loading branch information
H9660 authored Oct 4, 2022
2 parents 267e765 + 62273d6 commit 27cd74e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ARRAYS/CountPairsGivenSum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def getPairsCount(arr, n, sum):
#KUSHAL SINH VAGHELA
count = 0
for i in range(0, n):
for j in range(i + 1, n):
if arr[i] + arr[j] == sum:
count += 1

return count
arr = [1, 5, 7, -1, 5]
n = len(arr)
sum = 6
print("Count of pairs is",
getPairsCount(arr, n, sum))

0 comments on commit 27cd74e

Please sign in to comment.