A friend of mine is interviewing for a job. One of the interview questions got me thinking, just wanted some feedback.
There are 2 non-negative integers: i and j. Gi
Use a Min-heap.
Put 1.
extract-Min. Say you get x.
Push 2x and 5x into the heap.
Repeat.
Instead of storing x = 2^i * 5^j, you can store (i,j) and use a custom compare function.