Block interview question

General coding question - medium difficulty