1980.cpp (468B)
1 class Solution { 2 public: 3 string findDifferentBinaryString(const vector<string> &nums) { 4 const unordered_set<string> us(begin(nums), end(nums)); 5 const int n = nums.size(); 6 7 for (int mask = 0, crnt = 0; mask < (1 << n); crnt = ++mask) { 8 string s(n, '0'); 9 for (int i = n - 1; i >= 0; i--, crnt >>= 1) 10 if (crnt & 1) s[i]++; 11 if (!us.count(s)) return s; 12 } 13 return ""; 14 } 15 };