1. 1的數(shù)量 × 0的數(shù)量 + 1。數(shù)據(jù)類型用 long long int,過了95%。2. 瞪眼法,找不同,寫一串 if else。3. 看了好多解法都是 tire。我太菜了直接用哈希模擬做的。 if (op == 1) { hash[x]++; } else if (op == 2) { if (--hash[x] == 0) { hash.erase(x); } } else { long long int ret = -1; for (const auto& [a, b] : hash) { ret = max(ret, a ^ x); } } 復(fù)雜度O(n2),C++沒超時。