Untitled
unknown
c_cpp
2 years ago
415 B
22
Indexable
vector<vector<int>> solve(int n){ if(n%2 == 1){ return {{-1, -1}}; } vector<vector<int>> ans; vector<vector<int>> temp; for(int i = 1; i < n/2; i++){ int j = n - i; int val = i^j; val = 2*val; if(val == n){ ans.push_back({i, j}); temp.push_back({j, i}); } } for(int i = temp.size() - 1; i >= 0; i--){ ans.push_back(temp[i]); } if(ans.size() == 0){ return {{-1, -1}}; } return ans; }
Editor is loading...
Leave a Comment