Pregunta de entrevista de Yahoo

all of them are not difficult. basic C/c++ and algorithm problem