1class Solution {2public:3int shortestPathLength(vector<vector<int>> &graph) {4int n = graph.size();5string mask = "";6string eq = "";7for (int i = 0; i < n; i++) {8mask += '0';9eq += '1';10}11queue<pair<int, string>> q;12set<pair<int, string>> s;13for (int i = 0; i < n; i++) {14string temp = mask;15temp[i] = '1';16q.push({i, temp});17s.insert({i, temp});18}19int c = 0;20int flag = 0;21while (!q.empty()) {22int size = q.size();23for (int i = 0; i < size; i++) {24auto top = q.front();25q.pop();26if (top.second == eq) return c;27for (auto p : graph[top.first]) {28string temp1 = top.second;29temp1[p] = '1';30if (s.count({p, temp1}) == 0) {31q.push({p, temp1});32s.insert({p, temp1});33}34}35}36c++;37cout << "c is " << c;38}39return -1;40}41};