Skip to content

Instantly share code, notes, and snippets.

View Iyusuf40's full-sized avatar

Yusuf Isyaku Iyusuf40

  • Abuja Nigeria
View GitHub Profile
@Iyusuf40
Iyusuf40 / find_k_elements_that_sums_to.py
Last active January 3, 2025 23:13
Generalized find K elements in an array that adds up to a sum
# track number of iterations
BIG_O = 0
def find_k_numbers_that_add_upto_sum(arr, k, sum):
"""
A generic solution to the problem of Finding k numbers in an array
that add up to a given sum.
The solution is based on the assumption that the numbers in the array
are distinct.
- Works for both positive and negative numbers.
#!/usr/bin/python3
class Manager:
"""
Manages the call flow, serves as the midware manager
"""
def __init__(self):
self.__list = L_List()