Caladan interview question

Hackerrank with 3 questions. First 2 are coding last one is analysis.