mardi 3 février 2015

How to unit test a code with print statement?

Many a times, technical interviewers ask questions such as 'print something'. Eg: http://ift.tt/1x7lKqW


The following code will ask to print all paths from root to leaf.


How do I unit test a code like this ?


One solution would be to return a datastructure will all paths. But then interviewer would rebuke me for consuming huge space complexity ?


Aucun commentaire:

Enregistrer un commentaire