From the course: Get Ready for Your Coding Interview

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Visual solution to sample question #5

Visual solution to sample question #5

From the course: Get Ready for Your Coding Interview

Visual solution to sample question #5

- Here's my solution to sample interview question number five for Python dictionary or Hash Tables. The problem was finding a pair of numbers that add up to ten in a given Python list or rate. One potential solution here would be a brute force approach. In this approach we're going to check every potential pair of numbers in disarray and see if any of them add up to ten. We're going to start with the first pair three and four, since they add up to seven and not ten, we're going to go to the next pair three and one, which add up to four, and then we'll check three and two, three and nine and then four and one, four and two and so on. We're going to keep doing this until we find a pair that adds up to ten, which is one and nine, in this case. In the worst case scenario, the number of pairs we need to check here are N choose two, where N is the number of elements in this array. This is equal to N times and minus one over two,…

Contents