Hi all,
今天刷到一題
leetcode694 題目是
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's
(representing land) connected 4-directionally (horizontal or vertical.) You
may assume all four edges of the grid are surrounded by water.
Count the number of distinct islands. An island is considered to be the same
as another if and only if one island can be translated (and not rotated or
reflected) to equal the other.
先附上我的寫法還有解答
https://imgur.com/fnrJUsG
然後error message
https://imgur.com/ycaClM6
這邊想請問的是
我看我的寫法和解答的寫法除了他用inner
然後我的function 是define 在class 底下之外 應該是沒有什麼太大差別
(如果有錯誤請幫我指證謝謝)
這邊想請問的是 如果我是用inner function 做recursion
請問function return address是不是也是存在stack
如果是的話 想請問一下為什麼我的寫法會max recursion depth exceeded?
但是他的寫法卻可以過?
兩種recursion depth 應該要一樣不是?
謝謝!