Meta interview question

2 coding problems about matrix and trees