The Two Sum Problem The Two Sum problem is a classic algorithmic problem from leetcode that goes like this: given…