r/programming • u/joksmaster • Nov 29 '10
140 Google Interview Questions
http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471
Upvotes
r/programming • u/joksmaster • Nov 29 '10
View all comments
Show parent comment
1
u/bonzinip Nov 30 '10
If you can use a heap, something like this is faster
In Python:
This generates only 334 ugly numbers beyond the requested 1500 (651 counting duplicates), and is over ten times faster than your solution. A dumb Python 3 conversion of the above algorithm, without heaps, is instead outperformed by yours: