Sort 9 Discussions, By:
Please Login in order to post a comment
Once again, a problem setting where an elegant approach becomes dirty because of large number of tests, compromise in memoization and memory management.
Hint: the count of a given rectangle is , where . Generate a list of (the upper bound can be found easily), and then a list of all results, sort them and find the nearest result(s). If it is not for the last 2 test cases, the overall performance would be much more impressive (a few ms vs a few sec).
It is strange, 6 tests are failed, but I got status "Accepted"
Same thing happened with me ,i suggest you to handle the case where target is equidistant from two valid no. of rectangles possible .
can anyne help me with test cases so i can know where is the fault in my code
can we get testcases , atleast a few? some of my test cases are working but some are not. Out of a million possibilities it is hard to figure out the error in code ! help !!
create a few testcase, write a brute force and check
can you share few more test cases, my code executed sucessfully for first test case rest are failed.
I have been stuck with this for a while. What saved me was thinking about the rectangle 1999 x 1 and how many rectangles it contains ;-)