Welcome to MindCipher, a social repository of the world's greatest brain teasers, logic puzzles and mental challenges.

Microsoft Interview Question - Count it Out

This problem is more targeted towards people with Computer Science or similar backgrounds, it is a REAL question from an interview with Microsoft.

You have an array of 99 unique numbers from 0-100. What is the fastest (in computing) way to find the number between 0 and 100 that is not in the array?

add them up

Most people, when thinking of arrays, think of sorting algorithms. In this case, however, the problem is most easily and quickly solved by adding all the numbers in the array and subtracting the total from the sum of the numbers from 0 to 100.

The following C code demonstrates this solution (note that 50*101 is the sum of the first 100 integers):

//myArray is an array containing 99 unique numbers between 0 and 100 int currentTotal = 0; int findMissing(int myArray) { int ans; for(int i=0; i<99; i++) { currentTotal += myArray[i]; } ans = (50101) – currentTotal; return ans; }

Comments


Vivek Agrawal

just take xor of all numbers till 100and xor it with all elements of the array.You will get missing number


Vishal barot

nice question but it is easy


rjxxl1

I think this question might have a flaw in it. If the array has 99 unique numbers, but the number can be anything between 0 and 100, then there are TWO numbers missing, because there are 101 unique numbers between 0 and 100 (0 included). So adding them up and subtracting from 5,050 will give you the sum of the two numbers that are missing.

The question either is supposed to have unique digits between 1 and 100, or the array has 100 unique numbers.


ylq

seahawks jerseys, long champ, philipp plein clothing, bulls jerseys, okc jerseys, los angeles lakers, swarovski jewelry, coach outlet usa, prada tracksuits, toronto raptors jersey, air max, kate spade handbags, adidas.se, woolrich womens jackets, tommy hilfiger online, coach outlet online, chrome hearts rings, coach factory outlet online, saints jerseys, tommy hilfiger outlet, polo outlet, air max thea, oakley sunglasses outlet, nike shoes, toms outlet online, gucci store, cheap oakley, nike.dk, ralph lauren factory store, rolex, toms shoes outlet, hollisterco, stone island, spurs jerseys, mbt womens shoes, mcm bags, converse shoes, burberry outlet store, polo ralph lauren outlet, hilfiger outlet, ralph lauren outlet online, prada, moncler women jackets, broncos jerseys, michael kors, prada handbags, nike factory, adidas superstar, true religion jeans women, browns jerseys, michael kors uhren, hermes outlet, asics outlet, roshes, colts jerseys, the north face, oakley sunglasses, zapatillas nike, belstaff jackets outlet, designer handbags, replica watches, guess bags, tory burch, hogan, coach factory outlet online, fred perry outlet, replica watches, timberland boots, swarovski crystal, ray ban sunglasses, air max 2014, nike air max, nfl jerseys, bills jerseys, converse chucks, coach usa, kate spade outlet, northface, ralph lauren, portland trail blazers jersey, vikings jerseys, kate spade, polo ralph lauren, washington wizards jersey, omega watches, new orleans pelicans jersey, tods womens shoes, nike.se, marc by marc jacobs, polo outlet store, michael kors, atlanta hawks jerseys, mavericks jerseys, red bottom, coach usa, nike roshe run, belstaff mens jackets, marc by marc jacobs, cheap michael kors, rolex watches, hogan mens shoes, bengals jerseys, polo ralph lauren outlet online, toms shoes outlet, michael kors australia, puma shoes outlet, north face outlet, true religion outlet, nike roshe run, vans outlet, burberry outlet, north face jackets, oakley, polo ralph lauren, birkenstock deutschland, ray bans, nike free run, supra shoes, nike air force, tory burch handbags, givenchy shoes outlet, new balance, polo outlet online, michael kors outlet online, retro jordans, sacramento kings, ralph lauren, chi flat iron, polo ralph, cheap jerseys, ferragamo, 49ers jerseys, patriots jerseys, handbags outlet, nike mercurial vapor, chiefs jerseys, north face backpacks, kate spade bags, hilfiger online shop, eagles jerseys, ray bans, nike roshe run, swarovski australia, titans jerseys, new balance shoes, michael kors outlet online, mcm handbags, ralph lauren outlet online, versace outlet, nfl jerseys, fitflop shoes, new balance outlet, cheap oakley sunglasses, prada outlet, dsquared2, lac jersey, cowboys jerseys, jordan shoes, montblanc, pandora canada, cheap jerseys, michael jordan, pandora jewellery australia, iphone 4s cases, michael kors, true religion, polo ralph lauren, adidas shoes, nike air max, cheap ray ban, red bottom shoes, longchamp handbags, under armour shoes, oakley, barbour jacket outlet, orlando magic jersey, belstaff womens jackets, easton bats, bears jerseys, longchamp, north face, roshe run, ferragamo, redskins jerseys, chi hair, sunglasses for women, adidas online shop, nj jerseys, fendi, giants jerseys, rolex watches, hollister clothing, nike huarache, azcardinals jerseys, salomon schuhe, adidas superstar, burberry outlet store, nike free, louboutin shoes, ralph lauren, thomas sabo, bcbg max, nike huarache, gucci shoes store, michael kors outlet, steelers jerseys, nba jerseys, jordan retro, nike soccer shoes, coach factory online, dsquared2 outlet, pandora charms, soccer shoes, air jordan shoes, michael kors handbags, replica watches, nike store uk, burberry, nike air max, new balance, abercrombie, purses and handbags, juicy couture, true religion outlet, chargers jerseys, new balance, oakley sunglasses cheap, asics gel, under armour outlet, polo ralph lauren, ralph lauren outlet, burberry outlet online, salvatore ferragamo, ray ban uk, true religion jeans outlet, reebok outlet, michael kors handbags, lions jerseys, tommy hilfiger, michael kors bags, nike fu?ballschuhe, cavaliers jersey, babyliss flat iron, minnesota timberwolves jersey, air max 90, ed hardy clothing, jimmy choo outlet, the north face outlet, versace, converse outlet, thomas sabo jewellery, rayban, swarovski crystal, hogan sito ufficiale, coach bags outlet, 76ers jerseys, coach factory outlet, timberland outlet, falcons jerseys, timberland outlet, uggs outlet, burberry outlet online, rayban, celtics jersey, michael kors handbags, celine outlet, nike air max thea, longchamp taschen, ray ban outlet, buccaneers jerseys, g by guess, ferragamo shoes, fred perry polos, ray ban outlet, timberland, bottega veneta, cheap michael kors, ravens jerseys, oakley sunglasses, red bottom, ferragamo shoes, airmax, levis jeans, relojes, utah jazz jersey, tommy hilfiger canada, ralph lauren polo, veneta, ray ban pas cher, pandora charms, uhren shop, valentino outlet, christian louboutin outlet, pandora bracelet, toms outlet, prada shoes, the north face, oakley sunglasses, rayban, mcm handbags, cheap basketball shoes, skechers canada, air jordan retro, north face canada, panthers jerseys, nba jerseys, michael kors v?skor, bcbg max azria, nike running, jack wolfskin outlet online, denver nuggets jerseys, gafas oakley, lacoste shirts, eyeglasses stores, indiana pacers jersey, jimmy choo, nike roshe run, fivefingers, ray ban sunglasses, hollister online, nike free 5.0, hollister co, philipp plein, guciheaven outlet, giuseppe zanotti, c&c beanies, hornets jersey, ray ban occhiali, reebok, michael kors, oakley frogskins, juicy couture outlet, nike blazers, cheap nfl jerseys, hollister co, burberry online shop, birkenstock, christian louboutin shoes, michael kors outlet online, nike air huarache, cheap jack wolfskin, detroit pistons, barbour jackets, purses and handbags, moncler mens jackets, burberry sale, michael kors uk, nba jerseys, barbour jackets, cheap oakley sunglasses, lunette ray ban, fidget spinner, cheap jerseys, hermes birkin bag, nike air max, toms shoes outlet, michael kors outlet online sale, prada outlet, coach outlet online, nike tn, toms.com, ny jersey, thomas sabo uk, raiders jerseys, air max, ecco shoes outlet, hoodies store, warriors jerseys, burberry, calvin klein outlet, michael kors, burberry, michael kors purses, cheap shoes, ugg australia, easton bats, nike.com, miami heat, mcm backpack, polo ralph lauren, ray ban wayfarer, nike running shoes, christian louboutin, michael kors bags, adidas sneakers, oakley sunglasses, coach bags outlet, michael kors outlet online sale, ralph lauren polo, mizuno, pandora charms, replica rolex, jets jerseys, lacoste, dolphins jerseys, swarovski online shop, armani outlet online, adidas yeezy shoes, texans jerseys, coach shop, north face jackets, ralph lauren online shop, supra footwear, barbour mens jackets, mizuno running shoes, puma online shop, converse sneakers, nike air max, burberry handbags outlet, burberry outlet store, jordans for sale, nike store, coach black friday, vans schuhe, vans shoes, hollister, coach outlet sale, giuseppe zanotti sneakers, oakley sunglasses cheap, dansko shoes outlet, mont blanc pens, longchamp outlet, nike shoes, hugo boss outlet online, ipad mini cases, nike air max, michael kors handbags, www.tommyhilfiger.nl, cheap oakley sunglasses, jordan shoes, barbour womens jackets, jaguars jerseys, burberry sale, adidas, soccer shoes outlet, coach outlet store, rams jerseys, milwaukee bucks jersey, michael kors outlet, birkenstock taschen deutschland, adidas zx flux, montre homme, cheap jerseys, skechers womens shoes, ray ban wayfarer, louboutin, air max 2014, nfl jerseys, nike schoenen, oakley sunglasses outlet, cheap nike shoes, mcm handbags, packers jerseys, oakley sunglasses, suns jersey, hermes belt, ray-ban sunglasses, skechers outlet , rolex replica, memphis grizzlies jersey, cheap jerseys, houston rockets, swarovski, Hermès Pas Cher, longchamp handbags, pandora, oakley sunglasses, true religion jeans men, ray ban zonnebril, asics, nike running shoes, longchamp, coach bags outlet

Check out other puzzles:
Random  

Like this? You might also like:
Electrical Deaths
The Tallest Mountain
Happy Handshaking
Submitted by
Aakash
over 5 years ago
Likes
Difficulty 4.9 ?

Tags
None

Back