From the course: Get Ready for Your Coding Interview

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Sample interview question #5: Dictionary

Sample interview question #5: Dictionary

From the course: Get Ready for Your Coding Interview

Sample interview question #5: Dictionary

- [Instructor] Here's sample interview question number five, with Python dictionary or hash tables. Suppose you're given a Python list, or an array of numbers. What we want to do here is we want to be able to find a pair of numbers in this array that adds up to 10. In this example, one and nine add up to 10. For clarifying questions, you might ask, what should I return from my function? You should just print out the pair of numbers that adds up to 10 and return nothing. Could the numbers in the array be decimals? No, just assume that we'll only have integers. Could the numbers be negative? Yes, any of the numbers in the array could be negative or zero. What if I find two or more pairs that add up to 10? Then just print out one of them, and you can choose which one. What if there's no pair that adds up to 10? Then just print, "There is no pair that adds up to 10," and return from the function. And try solving this…

Contents