Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Least missing num
//Title of this code #include <iostream> #include <vector> #include <algorithm> using namespace std; int find(vector<int>& t, int first, int last) { int mid = (last - first) / 2 + first; if (last - first == 1) if (t[last] - t[first] == 1) return t[last] + 1; else return t[first] + 1; if (mid - first < t[mid] - t[first]) return find(t, first, mid); else return find(t, mid, last); } int main() { vector<int> t; t.push_back(1); t.push_back(2); t.push_back(3); t.push_back(4); t.push_back(5); t.push_back(8); t.push_back(9); t.push_back(8); t.push_back(9); t.push_back(10); sort(t.begin(), t.end()); std::cout << find(t, 0, t.size() - 1); }
run
|
edit
|
history
|
help
0
Round prices
Caminho das Pontes
Testing C++
Q
template
CutRod
HW0
horse aand goat working
cppPyAbs
Varadic macro