やるだけ
class ConsecutiveNumbers { public: vector <int> missingNumber(vector <int> ns) { vector<int> v; sort(ns.begin(), ns.end()); for (int i = 0; i + 1 < (int)ns.size(); ++i) { if (ns[i + 1] - ns[i] != 1) v.push_back(ns[i] + 1); } if (2 <= v.size()) return vector<int>(); if (v.empty()) { if (0 < ns.front() - 1) v.push_back(ns.front() - 1); v.push_back(ns.back() + 1); } for (int i = 0; i < (int)v.size(); ++i) { ns.push_back(v[i]); } sort(ns.begin(), ns.end()); for (int i = 0; i + 1 < (int)ns.size(); ++i) { if (ns[i + 1] - ns[i] != 1) return vector<int>(); } return v; } };