Pergunta de entrevista da empresa TikTok

Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order.