How to prevent re-checking already-checked data?
I have a class with a validId($id)
method that is called by the constructor and by public function load($id)
. The method queries the database to see if the id exists and returns true/false.
Quick algorithm to find matches between two arrays
I’m faced with the following problem:
Quick algorithm to find matches between two arrays
I’m faced with the following problem:
Least Change Problem with Thousands of Denominations
In a hypothetical economy there are currency units that can represent thousands of different values. So, for example there might be coins worth 1c, 3c, 5c, 7c, 7.5c, 80c, 8001.5c etc.
Least Change Problem with Thousands of Denominations
In a hypothetical economy there are currency units that can represent thousands of different values. So, for example there might be coins worth 1c, 3c, 5c, 7c, 7.5c, 80c, 8001.5c etc.
How can I approach creating an efficient algorithm for maximizing value with these specific constraints?
I’m having trouble coming up with an approach that isn’t n^2 for this problem. Here’s a contrived, simplified version I’ve come up with:
How can I approach creating an efficient algorithm for maximizing value with these specific constraints?
I’m having trouble coming up with an approach that isn’t n^2 for this problem. Here’s a contrived, simplified version I’ve come up with:
Simplicity-efficiency tradeoff
The CTO called to inform me of a new project and in the process told me that my code is weird.
When I test out the difference in time between shifting and multiplying in C, there is no difference. Why?
I have been taught that shifting in binary is much more efficient than multiplying by 2^k. So I wanted to experiment, and I used the following code to test this out:
When I test out the difference in time between shifting and multiplying in C, there is no difference. Why?
I have been taught that shifting in binary is much more efficient than multiplying by 2^k. So I wanted to experiment, and I used the following code to test this out: