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; } } cout << a << " " << b << 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
Generating π from 1,000 random numbers
binder
Iviewb
code_chef
string match
Tree
BubbleDouble
sdefrgthyjukiujyhtg
Primality Test | Fermat
Funny Saying