K&K interview question

Program on matrix are more difficult and lengthy