Please explain briefly

IN ELEPHANT PROBLEM ,HOW its time complexity is O(N^3)
and WHAT SHOULD BE ITS SPACE COMPLEXITIY???

@AMIT_KUMAR
For rat complexity is N^2
For elephant it is k*N^2
It is actually pretty simple
There are N^2 cells and you visit all of them
At each cell you add value of K cells on left and K cells on top of it which takes K time
So complexity becomes K*N^2

If your doubt is resolved please close it