Absolute Permutation Time : O(n) Space : O(n) 123456789101112vector<int> absolutePermutation(int n, int k) { vector<int> res; unordered_set<int> us; for(int i = 1; i <= n; i++) { if(i-k > 0 and !us.count(i-k)) res.push_back(i - k); else res.push_back(i + k); if(us.count(res.back())) return {-1}; if(res.back() > n) return {-1}; us.insert(res.back()); } return res;}