今際の国の呵呵君
Thursday, September 20, 2018
[LeetCode]Open the Lock
这道题很明显是图的问题,BFS找最短路径。按照题目的要求去找对应节点的相邻节点即可。时间复杂度O(8^d) = O(2^d),d为target距离起始状态0000的最短路径。代码如下:
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment