钥匙和房间
class Solution { public: void track_back(vector<vector<int>> &rooms ,vector<int> &keys , int indnx) { if(keys[indnx] != 0 ) return; keys[indnx]++; for(int i=0 ; i<rooms[indnx].size() ; i++) { track_back(rooms,keys,rooms[indnx][i]); } return; } bool canVisitAllRooms(vector<vector<int>>& rooms) { vector<int> keys(rooms.size() ,0); track_back(rooms,keys,0); for(int i=0 ; i<keys.size() ;i++) if(keys[i] == 0) return false; return true; } };