Category: Algorithm

Counting number contain 14 on n-digit number in less than 1 second

Counting number contain 14 on n-digit number in less than 1 second

My fellow Adiyat in our company POLATIC bug me with this question “How to counting number contain 14 in 10 millions numbers less than 1 second?”. Then I thought, it’s easy, let give python a shot! 1print len([x for x in range(0, 10000000) if str(x).find(’14’) > -1]) With result “590040” it’s takes 9.6s based on …

+ Read More