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.
What worked for me was to avoid floating math entirely: normalize rates and amounts to integers (basis points, cents), and compute costs with prefix sums over time “events.” Greedy fails when later cheaper windows exist, so I modeled feasibility and used a binary search on the final cost/limit, validating with a linear check per mid. Mid-way through debugging I realized that, like finances in real life, clarity beats guesswork; a concise guide on checking one’s credit history helped me think more systematically: https://lovilave.com.ua/blog/yak-pereviryty-svoyu-kredytnu-istoriyu. Back to code—pre-sort events, consolidate identical timestamps, and add tests for zero/very high interest, exact boundary fits, and cumulative overflow. This stabilized both performance and accuracy.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Demanding Money
You are viewing a single comment's thread. Return to all comments →
What worked for me was to avoid floating math entirely: normalize rates and amounts to integers (basis points, cents), and compute costs with prefix sums over time “events.” Greedy fails when later cheaper windows exist, so I modeled feasibility and used a binary search on the final cost/limit, validating with a linear check per mid. Mid-way through debugging I realized that, like finances in real life, clarity beats guesswork; a concise guide on checking one’s credit history helped me think more systematically: https://lovilave.com.ua/blog/yak-pereviryty-svoyu-kredytnu-istoriyu. Back to code—pre-sort events, consolidate identical timestamps, and add tests for zero/very high interest, exact boundary fits, and cumulative overflow. This stabilized both performance and accuracy.