diff --git a/g0rnn/DFS,BFS/4-g0rnn3.cpp b/g0rnn/DFS,BFS/4-g0rnn3.cpp new file mode 100644 index 0000000..1c4cdaf --- /dev/null +++ b/g0rnn/DFS,BFS/4-g0rnn3.cpp @@ -0,0 +1,19 @@ +#include +#include + +using namespace std; + +int dfs(vector& numbers, int target, int i, int value) { + if(numbers.size() <= i) { + return (target == value) ? 1 : 0; + } + + return dfs(numbers, target, i+1, value + numbers[i]) + + dfs(numbers, target, i+1, value - numbers[i]); +} + +int solution(vector numbers, int target) { + return dfs(numbers, target, 0, 0); +} + + diff --git "a/g0rnn/\354\212\244\355\203\235,\355\201\220/4-g0rnn.cpp" "b/g0rnn/\354\212\244\355\203\235,\355\201\220/4-g0rnn.cpp" new file mode 100644 index 0000000..0f7532e --- /dev/null +++ "b/g0rnn/\354\212\244\355\203\235,\355\201\220/4-g0rnn.cpp" @@ -0,0 +1,19 @@ +#include +#include + +using namespace std; + +vector solution(vector arr) +{ + vector answer; + + answer.push_back(arr[0]); + + for(int i=1; i +#include +#include + +using namespace std; + +vector solution(vector progresses, vector speeds) { + vector answer; + vector days; + + for(int i=0; i= days[i]) cnt++; + else { + answer.push_back(cnt); + cur_max = days[i]; + cnt = 1; + } + } + answer.push_back(cnt); + + return answer; +} \ No newline at end of file