Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Continuous Sub Set with given sum
//Title of this code #include <iostream> #include <vector> using namespace std; // O(n^2) // // n + (n-1) + (n-2) + (n-3) .... // // n * (n + 1) // 2 void continuousSubSet(vector<int>& t, int sumToFind) { for (int i = 0; i < t.size(); ++i) { int sum = 0; for (int j = i; j < t.size(); ++j) { sum += t[j]; if (sum == sumToFind) cout << i << " - " << j << endl; } } } int main() { vector<int> t; t.push_back(0); t.push_back(0); t.push_back(0); t.push_back(0); t.push_back(0); t.push_back(0); t.push_back(0); t.push_back(0); continuousSubSet(t, 0); }
run
|
edit
|
history
|
help
0
cppPySuper
Dar
Q
const example
QP
selection_sort
homework
no copy elision
codechef
¡Arriba, Papalotes, Arriba!