From the course: Get Ready for Your Coding Interview

Unlock the full course today

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

How should I test my code?

How should I test my code?

- Another very common question about coding interviews is how should I test my solution once I write it? To explain, let's use this really simple problem of finding the maximum number of a given rate. In this array or Python lists shown on the screen, five is the largest number. So we want to write a function that finds and returns this number. If you're given this problem in your coding interview, you might come up with a solution like this. Let's call our functions, find max. And we first initialize count max to none. We're going to use it to keep track of the maximum number we've seen so far. Then we're going to loop through the given list. If current max is still none here, the item we're looking at currently is the first item in the given rate. So we're going to update current max to item. If not, if item is larger than current max, then we're going to update current max too. In the end, after this loop, we'll return…

Contents