You are viewing a single comment's thread. Return to all comments →
I tried recursion. Works fine no memory issues
static long solve(int n, int m) { if(n==1 & m==1) { return 0; } else if((n==1 & m>1)||n>1 & m==1) { if(n>m) return n-1; return m-1; } else return (m-1)+m*solve(1,n); }
Seems like cookies are disabled on this browser, please enable them to open this website
Cutting Paper Squares
You are viewing a single comment's thread. Return to all comments →
I tried recursion. Works fine no memory issues