[MUSIC] So now that we have a strategy in mind, we're ready to move to the white board and actually start implementing it. Pretending that we're in the live interview situation. You'll be talking with an interviewer and you'll be working with them next to a white board. Which means that we're not coding in an IDE or even on a computer. And so the strategies that we have for describing our code on the white board will be a little bit different from what we've talked about before. Let's work with the example we have so far. And remember, our strategy for finding the k'th smallest element and the array is to first sort the array, and then just pick out the k'th element. And so, let's go ahead and write that. And at this point, we might have asked the interviewer whether we should assume that the method is public or private. And maybe they said it doesn't matter, or maybe they said that it was public. And so we start with our header. And we know that we're supposed to be returning the value of the k'th smallest element, and so we're returning an int. And we want a descriptive method name, and so maybe we call this kthSmallest. And as inputs, we have both the array of elements that we started with, as well as the rank. And so we have int array and we have the rank that we want to return. And so, here's our head method header. Now, the first thing we might want to do in our method is just make sure that we have some validation of the arguments and make sure that the parameters make sense. And so what we will do is check if (K i<=0 || K> array.length. In which case, it doesn't make any sense to ask for the k'th smallest. So in this situation, we want to thrown an exemption, because the arguments was just no good. And so, we're going to throw anew IllegalArgument Exception And that's that. But really, the heart of the strategy is going to be if we do have good arguments and then our plan was to sort, and we can use a library method for that. We've got arrays.sort(array) and then we're going to return the element in the case position after we've sorted the array. We have to be a little bit careful. Remember, we talked about what we're assuming k is indexed by, and if we're thinking of k as starting with one, so we're talking about the first smallest is the minimum and then the second smallest, etc. Then what we want to return is the element of the array[k-1], rather than k. And that will be that. And so what we have now on the board is a description of the algorithm that we've articulated for solving the problem. And what we would do now is perhaps walk through with an example. But before we do that, I want to step back away from the context of being in the interview and just talk a little bit about some good white boarding techniques and strategies. And so one thing you might notice in this sample code is that we used relatively meaningful names. So the method name is helpful to the reader as to what we're doing. Also in this code, I tried to keep a lot of space between the lines. And so if I needed to go in and then edit or add, or change some of the code later on, I would be able to fit some extra pieces of code in between the spaces. Because unlike a computer, we can't copy and paste. And we can't move things around very easily. And so it's good when we're first throwing some code on the board to try to give ourselves a potential for modifying it later. Something else you want to keep in mind is that you want to use variable names that are easy for the interviewer to see. So for example, K is a good choice for a letter that's being used for a variable name. You might say that if you were typing it up, you would use maybe an even more meaningful variable name like rink. But in the interest of time, so you don't have to write out all four letters each time, you're just going to use K. And a rule of thumb is that K is often a better choice than I or J, because those can, for one thing, look really similar to one another on the board. And also, they can be mistaken for semi-colons. You also want to make sure you're writing big enough and legibly, so that some one who is following along and reading with you can make sure they understand what's going on in the code, and then you can work on developing the algorithm further. And so at this point in the interview, the interviewer might go in a few different directions. They might ask for us to actually implement this sorting method instead of using a library call. Or they might ask us to go further with the algorithm. And so, that's what we'll do in the next video.