Python Program to find all pairs of an integer array whose sum is equal to a given number?

class Array:
def init(self,arr):
self.arr=arr
def is_pair_sum(self,n):
for i in range(0,len(self.arr)):
for j in range(i,len(self.arr)):
if (self.arr[i]+self.arr[j])==n:
print(self.arr[i],self.arr[j])
a=Array([1,2,3,4,5,6,7,8,9,0])
a.is_pair_sum(5)

2 Likes

@A_Abhiram
Nice :+1: keep it up

1 Like