We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #85: Counting rectangles
You are viewing a single comment's thread. Return to all comments →
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).