ZS Associates interview question

Hell or Heaven Puzzle