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 应该要一样不是?
谢谢!