In the first cracking the coding interview video Ms. McDowell talks about candidates that begin by writing test cases in whiteboard interviews. How would one go about this?
For example, the derivative problem in the video (the candidate is asked to write a function to take derivatives of a list of "Term" structs, which houses two integers, one for coefficients, and one for exponents), would you create a list of Terms, pass it into derivative(), and write the expected solution before even writing the code?
I'm thinking something along the lines of:
derivative([(10,50),(10,0)]) -> [(500,49), (0,0)] derivative([(5,2),(10,1),(5,5)]) -> [(10,1),(10,0),(25,4)]
is this what she means by writing test cases prior to writing code?