shouldn’t it be n-i+1 and m-j+1?
Doubt at timestamp 11:00
last cell index is n-1,m-1
so no of element form (i,j) to ( n-1.m-1) will be length *breadth of rectangle formed
length=(n-1-i+1)=(n-i)
breadth=(m-1-j+1)=(m-j)
so it should be (n-i)(m-j)
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course