JPMorganChase interview question

Technical Coding Question on 2D Matrix