Quora, Inc. interview question

Explain your code and how would you test it