Click here to see the full article post
@awice I have two questions: Firstly, although the function may call itself recursively, is it still true that we say it is a O(1) space? Secondly, would you please elaborate on time complexity O((R*C)^2). I do not get the square power completely.
It's O((R*C)^2) complexity because each function call scans the board three times so it's 3(R*C). If we only crush 3 candies each time, the function will be called (R*C)/3 times. Multiply those two terms together you get O((R*C)^2).
My similar solution though more verbose.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.