LeetCode 773. 滑动谜题


状态转移使用广度优先搜索
unordered_set可以hash string 但是不能用vector
注意广度优先搜索时,
若使用int step和 unordered_set<T>/vecotr<bool> visited,step每层加一而不是每次加一
或者不使用step,而是使用unordered_map<T ,int> dis
则dis[after]=dis[before]+1;
string.find()查找元素位置
swap()函数交换两元素

posted @ 2021-12-07 20:04  80k  阅读(27)  评论(0)    收藏  举报