Toeplitz Matrix[Medium] (Pramp-Java)

[[1,2,3,4],
[5,1,2,3],
[6,5,1,2]]
[[1,2,3,4],
[5,1,9,3],
[6,5,1,2]]
public boolean isTopelitzMatrix(int[] arr)
{
if(arr.length==0) return true;
for(int r=0; r<arr.length; r++)
{
for(int c=0; c<arr[0].length; c++)
{
if(r>0 && c>0 && arr[r-1][c-1] != arr[r][c])
{
return false;
}
}
}
return true;
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store