Raina: If your solution is recursive, use memoization, it will make your code way faster.
bodbod: check the console, you probably output something on the line before the 1. If you used an empty WriteLine for example it outputs a “\n” so it considers that you already answered.
I think this problem is on leetcode I discovered. I read you can use something like valleys or skyline. Where the dp states are the skylines. My understanding is that are filling in the rectangle with all possible squares and generating new skyline states.
This discusses a solution that I believe is along these lines. Although to be honest this code is a bit heavy. Not sure all that is needed. http://int-e.eu/~bf3/squares/
I believe it is okay to share this link because it doesn’t give a clear solution.
Thanks a lot @TwoSteps : i’ve effectively found a problem in my previous solution handling Validation 6 case …
-> corrected, so now Validator 6 is OK !
but Validator 4 still reports failure …
whereas in a real c++ IDE step by step testing mode returns … 7 !
=> I can’t understand where is my mistake, please ?
so disappointing …
EDIT : it seems to be a “not responding in time” error …
-> so correction found and apply works !
So : so happy, and thanks many a lot to you !!!
(regrets not to ask for help in time when it was the puzzle of the week !)
Hello,
I have been working on this problem on and off for a month.
I now have what I thought was a good solution but validator 7 still fails. Is there a way to know the parameters (w,h) for this case ?
I actually started this problem in May, and gave up only to come back to it now. My code works in my IDE, I get the right results including the validators, which si very satisfying! But it takes too much time in CG (in my IDE, validator 7 takes several minutes). I’m pretty much a beginner, but I enjoy it
I’m doing a brute force recursion search in C++, starting with the biggest possible squares and decreasing in size with every iteration, and stopping the search after n iterations where n is the previously found minimum number of squares. I think this method is to the order of O(n^2) or even worse, because smaller rectangles are very quick to figure out.
Hi @Pavallin ! if i can give you a tip : try to get in memory and reuse (it is possible within the same testcase) the results of your already solved config, instead of solving the same rect again and again …
→ It may give you enough time to parse all successfully !