diff --git a/001_RECURSION/013_Rope Cutting Problem/main.cpp b/001_RECURSION/013_Rope Cutting Problem/main.cpp new file mode 100644 index 0000000..76a8af8 --- /dev/null +++ b/001_RECURSION/013_Rope Cutting Problem/main.cpp @@ -0,0 +1,33 @@ +// Description: +/*You are given N ropes. A cut operation is performed on ropes such that all of them are reduced by the +length of the smallest rope.Display the number of ropes left after every cut operation until the +length of each rope is zero. +*/ +#include +using namespace std; + + +int maxCuts(int n, int a, int b, int c) +{ + if(n == 0) + return 0; + if(n <= -1) + return -1; + + int res = max(maxCuts(n-a, a, b, c), + max(maxCuts(n-b, a, b, c), + maxCuts(n-c, a, b, c))); + + if(res == -1) + return -1; + + return res + 1; +} +int main() { + + int n = 5, a = 2, b = 1, c = 5; + + cout<