0
点赞
收藏
分享

微信扫一扫

leetcode-79-Word Search

西曲风 2023-08-23 阅读 61


Used search method to deal with this, just set a struct to store current element is used or not, then go to 4 direction then check if next step is match current string. Do this again and again until the cur meet the end or nothing to match.

The thing I learn is instead of use void like before, I used a function to return the value. I think here the key is do not do pruning or pre-processing. Just check the state in the next step. It means that our process is:

goto function -> judge -> goto function -> judge

However, before my process is:

judge -> goto function -> judge -> goto function

Error:
We need to check if its out of range then check current element in board is the same as word

Update:
Do not use previous pruning approach, use the make scene definition! Remember to check visit and set back visit after traverse


举报

相关推荐

0 条评论