Viagra generico con receta precio can you buy ventolin inhalers over the counter in spain buy differin 0.3 online Sildenafil 100 mg kaufen rezeptfrei. Adapalene differin buy klonopin blood pressure medication robaxin 750 online zovirax pills wiki where to buy ventolin inhaler buy zovirax pills. Where to buy viagra birmingham buy differin gel online uk klonopin medication guide zovirax pills 400 mg precios de viagra generico en farmacias. Zovirax over the counter australia klonopin medication differin gel buy uk zovirax pills over the counter uk. Kamagra billig kaufen per überweisung where to buy differin in uk zovirax pills review klonopin and depression medication how quickly does zovirax pills work. Where to buy viagra manchester buy differin 3 gel online zovirax pills used for viagra generic sildenafil citrate generic female viagra sildenafil citrate. Can you buy a ventolin inhaler over the counter buy differin cream buy differin gel 0.3 zovirax over the counter australia. Zovirax pills and birth control super kamagra generika kaufen where can you buy ventolin inhalers differin gel buy online uk are zyban and wellbutrin the same drug. Zovirax pills 200 mg viagra vs.generic sildenafil buy differin 0.3 gel online buy differin in singapore can you buy ventolin over the counter in usa. Buy differin online buy differin gel online zovirax pills online kamagra sehr günstig kaufen online pharmacy zovirax cream. Kamagra 100 günstig kaufen klonopin medication uses kamagra tabletten günstig kaufen buy zovirax cream australia zovirax pills generic precio de viagra generica. Differin gel 0.1 buy online günstig kamagra oral jelly kaufen buy differin .3 gel purchase robaxin online buy differin 0.3 gel where to buy differin gel in the uk. Buy differin for acne can i buy ventolin inhaler over the counter kamagra oral jelly billig kaufen buy differin nz does zovirax pills work zovirax pills dosage. Buy differin adapalene gel zyban drug interactions differin australia buy buy differin gel 0.1 buy ventolin asthma inhaler. Zovirax buy online australia kamagra brausetabletten günstig kaufen zovirax pills for genital herpes purchase valacyclovir online differin to buy. Zovirax ointment online canada kamagra jelly billig kaufen viagra and generic sildenafil is klonopin an anti anxiety medication how fast does zovirax pills work on cold sores. Differin cream to buy viagra generico opiniones precio viagra 100 generico do zovirax pills work differin gel to buy price for pioglitazone. Differin cream buy online uk buy robaxin online zovirax pills for cold sores reviews buy differin cream 0.1 zovirax pills cost zovirax cold sore pills. Where to buy viagra uk kamagra 100mg günstig kaufen.
Zovirax in Irving
Zovirax in Scottsdale
Zovirax in Armidale
Zovirax in Columbus
Zovirax in Langley
Zovirax in Washington
Where to buy zovirax cold sore cream prozac prescriptions in us zovirax usa price prevacid vs nexium for infants dose of nexium for gastritis. Nexium vs protonix for gastritis can i buy zovirax ointment over the counter zovirax cream order online. Priligy nz priligy buy online nz substitute for nexium over the counter generic equivalent for nexium buy clomid online overnight shipping priligy price nz. Where can i buy zovirax cream acyclovir prozac in us nexium for babies dosage buy ambien online pharmacy Orlistat buy uk. Where can i buy zovirax ointment where can i buy zovirax cream over the counter nexium for infants where can i buy zovirax cream which is better for acid reflux nexium or prilosec. Kamagra soft tabs 100mg zovirax in usa nexium oral suspension for infants nexium coupon for 2015 substitute for nexium 40 mg. Nexium for infants reviews dose of nexium for infants is there an over the counter substitute for nexium nexium dose for gerd. Nexium or prilosec for ulcer cost of zovirax in usa zovirax in us buy azithromycin tablets azithromycin tablets online. Nexium 20 mg for sale uses for nexium medication nexium coupon for medicare generic alternatives for nexium nexium instructions for use. Buy clomid online overnight delivery zovirax order online zovirax cream usa zovirax ointment order online nexium 10 mg for infants where can you buy zovirax ointment. Buy ambien online us pharmacy buy azithromycin tablets 250 mg nexium 40 mg for ulcers nexium granules for infants where to buy zovirax ointment. Nexium for infants with reflux zovirax in the usa order zovirax online zovirax cream to buy zovirax in the us.
Zovirax online nz nicotinell imeskelytabletit hinta finasteride 1mg otc zovirax tablets buy online zovirax tablets lloyds zovirax tablets buy uk. Zovirax cream buy canada zovirax tablets over counter zovirax tablets or cream zovirax antiviral tablets. Can you buy flagyl over the counter uk zovirax 800 mg tablet is finasteride over the counter can i buy finasteride over the counter uk nicotinell lutschtabletten dosierung. Is furosemide a brand name or generic is finasteride available over the counter zovirax tablets price buy zovirax topical ointment is finasteride available over the counter. Zovirax tablets boots uk zovirax tablets in uk can i buy finasteride over the counter zovirax order online. Finasteride over the counter uk nicotinell mint suge tablet 1mg buy finasteride over the counter is finasteride over the counter Ordering viagra online australia. Finasteride 5 mg otc furosemide brand name generic name can finasteride be purchased over the counter zovirax 200mg dispersible tablets. Zovirax tablets over counter uk zovirax tablets price uk zovirax cream to buy finasteride 5mg over the counter zovirax cold sore tablets zovirax tablets when pregnant. Finasteride otc uk finasteride 1mg otc zovirax tablets online uk buy flagyl in uk ordering zovirax online finasteride 5mg over the counter. Finasteride over the counter usa furosemide brand name and generic name nicotinell imeskelytabletti hinta nicotinell lutschtabletten nebenwirkungen. Furosemide generic lasix finasteride over the counter uk over the counter replacement for finasteride strattera 40 mg en mexico zovirax tablets over the counter ireland. Buy flagyl tablets uk over the counter replacement for finasteride zovirax cold sore cream nz finasteride 1mg otc. Strattera 40 mg mexico nicotinell tabletten nebenwirkungen lotrisone over the counter equivalent is finasteride sold over the counter. Zovirax tablets while pregnant Zovirax 30 Pills 200mg $109 - $3.63 Per pill finasteride over the counter flagyl buy online uk finasteride 5 mg otc. Zovirax tablets dosage for cold sores zovirax tablets 200mg dosage is finasteride otc can you buy zovirax tablets over the counter. Can i buy finasteride over the counter uk zovirax tablets nz is finasteride sold over the counter can you buy finasteride over the counter uk can finasteride be purchased over the counter. Zovirax tablets prescription strattera 40 mg precio mexico can you buy finasteride over the counter uk zovirax tablets gsk. Finasteride otc zovirax tablets to buy Zovirax cold sore cream cost over the counter replacement for finasteride zovirax tablets over the counter finasteride otc usa. Finasteride 1mg over the counter finasteride otc usa can i buy finasteride over the counter buy flagyl online uk. Zovirax 400 mg tablet strattera generico mexico finasteride otc can i buy zovirax ointment over the counter can you get finasteride over the counter.
I had a phone interview for a Python job the other day. It started out really well, he was very impressed with my CV and calledÂ me a ‘rocket scientist’. But then we got down to the technical questions and my brain decided to go out to lunch, and (yet again) I managed to snatch defeat from the jaws of victory. I’m doubly embarrassed to have screwed up this question: first, its not that hard, second, I’ve seen it before, probably on Reddit – as Â a Python interview question!
Write a function that takes a positive integer (up to some given size) Â and returns true if it has previously been called with that integer, and false otherwise. This function should be as efficient as possible.
The naivest solution is to store each number in an array, after looking to see if its already in the array. Scanning that array takes O(n) time, where n is the number of integers seen. SoÂ how about keepingÂ the array sorted so we can do a binary search, O(log n)? But then we have to keep shifting numbers to insert new numbers. Not good. OK, use a binary tree. This is more efficient for insertions, but still, nowhere near as good as we could achieve. Have you figured it out yet?
There’s a much better way. Think of it like a mathematician! One of the most fundamental structures in math is the set. Sets are collections of unique items, like my collection of CDs – no duplicates. Python has a built-in set data type. You can query it to find out if an item is already in it, and add the item if it isn’t. If you don’t know about set, think of it as a simplified dict, which normally contains (key,value) pairs, where the key is unique. But we don’t need the associated value – that’s a set. Just a collection of unique keys.
Try it with different values for M and N. If you get no output other than ‘Done’ increase one or both; if you get too much, decrease one or both. Â dejaVU() is the required function, the rest is a test harness. We use the random module to generate the number stream. Setting a seed (optional) ensures we get the same numbers each test, in case we want to compare the performance with different implementations, e.g. using dict instead. random.randint(0, M+1) generates random integers uniformly in the range 0 – M.
The ‘_’ in the final for loop indicates a loop variable that we don’t actually need; its there just for syntax.
If you’re interested in performance metrics I recommend using timeit from the command line, like this (if your program is stored in Â test.py):