Developer Interview Questions in United States
developer interview questions shared by candidates
Top Interview Questions
A frog is at the bottom of a 30 meter well. Each day he summons enough energy for one 3 meter leap up the well. Exhausted, he then hangs there for the rest of the day. At night, while he is asleep, he slips 2 meters backwards. How many days does it take him to escape from the well? 560 Answerstry to answer this question as seriously as u can 28 I agree -- it's 28...because on that morning, he'll be at 27 metres and he can jump to the top in one bound. Show more responses Answer: 28 Each day he makes it up another meter, and then on the twenty seventh day he can leap three meters and climb out. It's 29 - on the 28th day he can leap 3 meters and hang at the top (but he can't climb higher & out), and on the 29th day he'll leap and be out of the well at 31 meters. 27 At day 0, he jumps to 3m. At day 27, he jumps to 30m and gets out. 28. Each night he ends up/starts the next morning at the number of days he's been there (first night, he's at 1 foot, 2nd night he's at two feet). Hence, on the 28th day he jumps 3 feet to 30 feet. 28 days. At start of day 27, he jumps 3m to reach the top of the 30m well but has no energy left to climb out. At start of day 28, he jumps another 3m and entirely out of the well. Never....the frog would be dead by day 10 since nothing to eat or drink. 28 Saying 28 is too easy. What about the external (1) and internal factors (2): (1) there might be a heavy rain during the first night and the frog can easily float up or, ..., drown, at all; (2) the frog may decide it's sunday - let's have a rest and spare the energy for a bigger jump on the next day... 27 days Day 1 - It jumps 3 meters. 0 + 3 = 3. Then falls back 2 at night. 3 - 2 = 1 Day 2 - It jumps 3 meters. 1 + 3 = 4. Then falls back 2 at night. 4 - 2 = 2. ... Day 26 - It jumps 3 meters. 26 + 3 = 29. Then falls back 2 at night. 29 - 2 = 27. Day 27 - It jumps 3 meters. 27 + 3 = 30 This question is ambiguous whether if the frog is able to get out when it reaches the top or if it needs to exceed 30 meters to climb out. Assuming it doesn't die of starvation, the answer is 28 days.* start of day 1 (0 days elapsed): 0m --> 3m (then falls back 2m by start of day 2) start of day 2 (1 day elapsed): 1m --> 4m start of day 3 (2 days elapsed): 2m --> 5m ... start of day 28 (27 days elapsed): 27m --> 30m start of day 29 (28 days elapsed): 28m --> 31m In other words, 28 days will have elapsed before the frog can jump to a height exceeding 30m.* * This answer assumes the frog is not able to walk away after it hits 30m. I would assume it has no energy left to climb out based on the problem description. If the questioner disagrees with this assumption, then the answer is 27 days. Show more responses 28 27 ..... he will jump 3 meters this day to get out!!! The math certainly says 27, assuming he only needs to get to 30m to actually get out. its easy to forget that, as pointed out by Paul, he can jump at the beginning of the day, therefore he can reach 3 meters in 0 days. I like the out-of-the-box notions presented by HB and nic. Maybe croaking could get him some help from someone. Maybe he could get up in a well bucket. Why does he want to leave? -- maybe he has everything he needs there and is safe from predators. Why does he slip down? Can he stop that? I wonder what they're looking for in a question like that. I wonder if it really helps them choose good candidates. I wonder who's going to bother reading this. No math necessary. Frog is dead after a few days. 27!! as he will be out on the same day. it will be 28 if he spends the night as well. and c'mon, frog is not based on a binary system, that he wont have enough energy after the last 3 meter, he sure will be motivated enough to take the 3.000001 meteres on the last day to get out of the damn well. 27 days It is 28 assuming reaching 30 ft gets him out of the well, people saying 27 are making the error of assuming there is a day zero, when counting days as with years there is no 0. 28. 27 days to get to go to sleep on level 27. Next day outa da hole. Most frogs have to surface for air. After a short amount of time they will die without air unless they are in aerated water and can absorb through skin. So ask what species is the frog. Day 1: 0 + 3 = 3 - 2 = 1, D2: 1 + 3 = 4 -2 = 2, D3: 2 +3 = 5 - 2 = 3....D28: 27 + 3 = 30 -2 = 28, D29: 28 + 3 = Eaten by the bird that has been waiting for him.... Show more responses bllshit If Mr. Frog manages to make it up the wall another meter everyday then, on the 27th day, he can leap three meters and climb out, the answer would be 28 days... 28 days. As the frog slips 2 meters down every night by the 27th day he has climbed 27 meters. On 28th, the frog will start from the point of 27m which means start climbing 3 meters foward and this way he reaches his 30m to get out. 28days NB - he does 3m/day, but the result in the next morning b4 his next jump is 1m jump the previous day In the morning of day 26 b4 he jump, he has 5m left...meaning he has done 25m for 25days. On day 26, he jumps 3m, leaving him wit 2m to go but cos he sinks 2m overnight, the4 his resulting meters to go is 4m On day 27, he jumps 3m and left with 1m but sinking 2m more means the resulting meters to go is 3m On day 28, he complete his 30m and walk out from the well victorious provided no predator in the well and he didnt die of starvation 28 days... kermit the frog? How much water is in the well? Frogs need water to survive. What about food? 27th day How did the frog get in the well in the first place? What is motivating him to get up? How does he know he can get out? If the frog slips two meters every night for 27 nights he will be very sad and wont try anymore so he will never get out. Wait....I am this frog! x = number of days A = 30 meters x+2 = A x + 2 = 30 x=28 Show more responses Thirty days as he is only moving one meter a day. What kind of Frog is it? Is the well full of Water? My first thought is that the frog would not survive, Food and air seem the best bet for Frog-a-cide. Of course if the question is mathematical only in nature then you would have to follow the logic above x=number of days y=30 meters x+2=y x+2=30 x=28 Hey guys ... Its simple don't break your head.... 30 feet well OK 1 day 3 feet jump and sleeping and falling down to 2 feet.. So the frog can only climb up 1 feet per day... so on 26th day it was in 26 th feet and jumped and it reached to 29th feet and sleeping and falling down to 2 feet down.. so on 27th day it was in 27th feet jumped and it reached to 30 feet and went out of the well.. bec after reaching the 30th feet why the hell does the frog gonna sleep again. So it took 27 days for the frog to come out of the 30 feet well. Question created by me... so answered it....lolzzzzzzzzzzz Answer: Day 28 Day 1 - It jumps 3 meters. 0 + 3 = 3. Then falls back 2 at night. 3 - 2 = 1 Day 2 - It jumps 3 meters. 1 + 3 = 4. Then falls back 2 at night. 4 - 2 = 2. ... Day 26 - It jumps 3 meters. 25 + 3 = 28. Then falls back 2 at night. 28 - 2 = 26. Day 27 - It jumps 3 meters. 26 + 3 = 29 Then falls back 2 at night. 29 - 2 = 27. Day 28 - It jumps 3 meters. 27 + 3 = 30 Note: Assume after the first leap that his hind legs are exactly three meters up the well. His hind legs must clear the well for him to escape. Answer: Day 29 Remember that on Day 1 the frog ends at 1 meter, Day 2 the frog ends at 2 meters, ... So on Day 27, the frog end at 27 meters. On Day 28, the frog goes up to 30 meters, then back down to 28 meters. On Day 29 the frog finally makes it to 31 meters (out of the well). This will help if you are still not convinced: int height = 30; int curPos = 0; int days = 0; while(curPosheight){ break; } curPos -=2; if(curPos>height){ break; } } System.out.println(days); } ITS ONLY 10 DAYS. Because, if he waits 10 days, he will summon the strength to jump 30 meters in one jump to the top of the well. Ya'll can't think outside the box... Cool Show more responses I know this isn't the right answer but if u think VERY VERY logically, well, he doesn't. 30 days Day 1 -> Total distance Covered = 3-2 = 1m Day 27 -> 1*27 = 27 Day 28 -> 27+3 = 30 and the frog and he escapes 28 will be the final answer Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses Show more responses i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 Show more responses I will forever be indebted to the great Doctor Tebe for fixing my broken marriage after my husband left me for his mistress for 6 months. I never believed in spells until my friend introduced me to him. At first, I was skeptical about him because I heard a lots about false spell casters but I put my doubts behind me for i was desperate to get my husband back and I did according to what he instructed me to do. Now my husband is back just within 48 hours of contacting him. I'm living happily with my husband again after 6 months of divorce and I will not rest till he's known all over the world. He's also specialize in money spells, lottery spells, sickness spells E.T.C. Get connected with Doctor Tebe now, his email is drtebe1@gmail. com or WhatsApp on +2348140544262. Show more responses i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 Show more responses i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 i want to let the world know about Dr, Paul the Great spell caster that brought back my husband to me when i thought all hope was lost. Dr,Paul used his powerful spell to put a smile on my face by bringing back my man with his spell, at first i thought i was dreaming when my husband came back to me on his knees begging me to forgive him and accept him back and ever since then he loves me more than i ever expected so i made a vow to my self that i will let the World know about Dr, Paul because he is a God on earth. Do you have problems in your relationship ? have your partner broke up with you and you still love and want him back ? Do you have problem with your finance ? or do you need help of any kind then contact Dr, Paul today for i give you 100% guarantee that he will help you just as he helped me. Dr, Paul email is: astoriashrine@ gmail com OR dd him on whatsapp via: +2349051441669 Show more responses Show more responses Show more responses Show more responses Just wanted to call out Paul for his fantastic service through my home buying process - from identifying the best rate through to obtaining approval and settlement. This was my first home purchase and I think it's fair to say that it would have been significantly more challenging without his help. Paul was on top of everything that needed to be done - going the extra bit in dealing with the bank and conveyance to ensure that the whole process was concluded smoothly. The best part was that Paul was always there to answer any questions and provide support, making life much simpler. Highly recommended! www.westernloanfinance.com Just wanted to call out Paul for his fantastic service through my home buying process - from identifying the best rate through to obtaining approval and settlement. This was my first home purchase and I think it's fair to say that it would have been significantly more challenging without his help. Paul was on top of everything that needed to be done - going the extra bit in dealing with the bank and conveyance to ensure that the whole process was concluded smoothly. The best part was that Paul was always there to answer any questions and provide support, making life much simpler. Highly recommended! www.westernloanfinance.com Show more responses Show more responses Show more responses Show more responses Show more responses When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Show more responses When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Show more responses Just wanted to call out Paul for his fantastic service through my home buying process - from identifying the best rate through to obtaining approval and settlement. This was my first home purchase and I think it's fair to say that it would have been significantly more challenging without his help. Paul was on top of everything that needed to be done - going the extra bit in dealing with the bank and conveyance to ensure that the whole process was concluded smoothly. The best part was that Paul was always there to answer any questions and provide support, making life much simpler. Highly recommended! www.westernloanfinance.com When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Show more responses Show more responses Show more responses Show more responses Get your ex back from a real love spell caster with Dr Paul at his email at astoriashrine@ gmail com within 48 hours instantly. I am very happy for contacting Dr Paul who helped me get my ex husband back from another woman after 3 years of separation. I am very happy because I never believed in spell casting and contacting spell casters to solve my problem but after 3 years of separating from my husband being single, I had to contact Dr Paul after I read about him online and how he has been helping people. I am very glad I did. My husband came back to me within 48 hours, begged me and the kids who needed their father back with them and I am very happy. I found this man through testimonies that he can solve pregnancy and love problems that is why I contacted him to help me and within 48 hours my husband came back home and we are living happily together. His email is astoriashrine @ gmail com or Whats-app number on +2349051441669 Get your ex back from a real love spell caster with Dr Paul at his email at astoriashrine@ gmail com within 48 hours instantly. I am very happy for contacting Dr Paul who helped me get my ex husband back from another woman after 3 years of separation. I am very happy because I never believed in spell casting and contacting spell casters to solve my problem but after 3 years of separating from my husband being single, I had to contact Dr Paul after I read about him online and how he has been helping people. I am very glad I did. My husband came back to me within 48 hours, begged me and the kids who needed their father back with them and I am very happy. I found this man through testimonies that he can solve pregnancy and love problems that is why I contacted him to help me and within 48 hours my husband came back home and we are living happily together. His email is astoriashrine @ gmail com or Whats-app number on +2349051441669 Show more responses I will forever be indebted to the great Doctor ojoka for fixing my broken marriage after my husband left me for his mistress for 3 months. I never believed in spells until my friend introduced me to him. At first, I was skeptical about him because I heard a lots about false spell casters but I put my doubts behind me for i was desperate to get my husband back and I did according to what he instructed me to do. Now my husband is back just within 48 hours of contacting him. I'm living happily with my husband again after 6 months of divorce and I will not rest till he's known all over the world. He's also specialize in money spells, lottery spells, sickness spells E.T.C. Get connected with Doctor ojoka now, his email him drojokaspelltemple@gmail com or Whats App on +2348144172934 I will forever be indebted to the great Doctor ojoka for fixing my broken marriage after my husband left me for his mistress for 3 months. I never believed in spells until my friend introduced me to him. At first, I was skeptical about him because I heard a lots about false spell casters but I put my doubts behind me for i was desperate to get my husband back and I did according to what he instructed me to do. Now my husband is back just within 48 hours of contacting him. I'm living happily with my husband again after 6 months of divorce and I will not rest till he's known all over the world. He's also specialize in money spells, lottery spells, sickness spells E.T.C. Get connected with Doctor ojoka now, his email him drojokaspelltemple@gmail com or Whats App on +2348144172934 Show more responses Show more responses Show more responses Show more responses Show more responses When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Show more responses When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Show more responses When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 When I found Dr. Paul I was in desperate need of bringing my ex lover back. He left me for another woman. It happened so fast and I had no say in the situation at all. He just dumped me after 3 years with no explanation. I contact Dr.Paul through his website and He told me me what i need to do before he can help me and i did what he told me to, after i provided what he wanted, he cast a love spell to help us get back together. Shortly after he did his spell, my boyfriend started texting me again and felt horrible for what he just put me through. He said that I was the most important person in his life and he knows that now. We moved in together and he was more open to me than before and then he started spending more time with me than before. Ever since Dr. Paul helped me, my partner is very stable, faithful and closer to me than before. I highly recommends Dr. Paul to anyone in need of help. Email: astoriashrine@ gmail com, Call him or add him on whatsapp via: +2349051441669 Show more responses Show more responses My husband and I have been married for about 7 yrs now. We were happily married with two kids, a boy and a girl. 3 months ago, I started to notice some strange behavior from him and a few weeks later I found out that my husband is seeing someone. He started coming home late from work, he hardly care about me or the kids anymore, Sometimes he goes out and doesn't even come back home for about 2-3 days. I did all I could to rectify this problem but all to no avail. I became very worried and needed help. As I was browsing through the Internet one day, I came across a website that suggested that Dr sirdoma can help solve marital problems, restore broken relationships and so on. So, I felt I should give him a try. I contacted him and he did a spell for me. Two days later, my husband came to me and apologized for the wrongs he did and promise never to do it again. Ever since then, everything has returned back to normal. I and my family are living together happily again.. All thanks to Dr sirdoma . If you need a spell caster that can cast a spell that truly works, I suggest you contact him. He will not disappoint you. This is his nubmer ; +2347010313315 1)lotto spell 2)promotion spell 3)protection spell Show more responses Please if you are having issues with your relationship or marriages I advice you to contact Dr Charles he can help you as well. WhatSApp: +2348146708557 Show more responses I completely trusted Dr Paul totally from the time I spoke with him during the period my husband Left me after11 years of our marriage, He started the spell work on my husband, and gave me so much assurance and guaranteed me that he was going to bring my husband back to my feet in just 48 hours of the spell casting. I was so confident in his work and just as he said in the beginning, my husband is finally back to me again, yes he is back with all his hearts, Love, care, emotions and flowers and things are better now. I would have no hesitation to recommend this powerful spell caster to anybody who is in need of help.. E-mail; astoriashrine @ gmail com I completely trusted Dr Paul totally from the time I spoke with him during the period my husband Left me after11 years of our marriage, He started the spell work on my husband, and gave me so much assurance and guaranteed me that he was going to bring my husband back to my feet in just 48 hours of the spell casting. I was so confident in his work and just as he said in the beginning, my husband is finally back to me again, yes he is back with all his hearts, Love, care, emotions and flowers and things are better now. I would have no hesitation to recommend this powerful spell caster to anybody who is in need of help.. E-mail; astoriashrine @ gmail com I completely trusted Dr Paul totally from the time I spoke with him during the period my husband Left me after11 years of our marriage, He started the spell work on my husband, and gave me so much assurance and guaranteed me that he was going to bring my husband back to my feet in just 48 hours of the spell casting. I was so confident in his work and just as he said in the beginning, my husband is finally back to me again, yes he is back with all his hearts, Love, care, emotions and flowers and things are better now. I would have no hesitation to recommend this powerful spell caster to anybody who is in need of help.. E-mail; astoriashrine @ gmail com Show more responses I completely trusted Dr Paul totally from the time I spoke with him during the period my husband Left me after11 years of our marriage, He started the spell work on my husband, and gave me so much assurance and guaranteed me that he was going to bring my husband back to my feet in just 48 hours of the spell casting. I was so confident in his work and just as he said in the beginning, my husband is finally back to me again, yes he is back with all his hearts, Love, care, emotions and flowers and things are better now. I would have no hesitation to recommend this powerful spell caster to anybody who is in need of help.. E-mail; astoriashrine @ gmail com Show more responses One or more comments have been removed. |
Out of 25 horses, pick the fastest 3 horses. In each race, only 5 horses can run at the same time. What is the minimum number of races required? 68 Answers7 races. 6 races. After running 5 you have the 5 fastest horses out of 25. Run 1 more race of 5 horses to get the fastest 3. 8 races Show more responses The above answer is not right. The correct answer is 8 races. Sid's answer is incorrect. The correct answer is 7 races. 7 races. We run five races with five horses. The five winners race in a sixth race while the 4th and fith place finishers are eliminated from further consideration. The sixth race show horse is faster than all the horses that participated in the preliminary races where the 4th and 5th place horses participated and they are eliminated from further consideration. The other horses in the preliminary race where the 6th race show horse participated are also eliminated. The show horse in the preliminary race where the 6th race place horse participated is eliminated since there are at least three remaining horses that are faster. We are left with 6 horses. We know the winner of the 6th race is fastest overall, so that leaves five horses to enter a 7th race for the overall place and show. Seems to me the correct answer is five. Assuming that each horse's performance is timed, by running five races with five horses each, you'll know the speed of all 25 horses. The three with the shortest times are the three fastest horses. Most responses assume you need multiple rounds, but these responses seem to assume that the five horses that finish first in the first round are the fastest five overall. That may not be the case. Just because a horse beat its four competitors doesn't mean it's one of the five fastest overall ... just that it was faster than the four it competed against. Consider: 5 races will ensure that each horse runs once. In race #1, the margin of victory could be so insignificant that the difference between horse #1 and horse #5 is.05 seconds (with 2nd place .02 behind, 3rd place .03 behind, 4th place .04 behind). The horse that finishes in 5th place in race #1 could actually be the 5th fastest horse of the 25. You wont know this of course until all 25 horses have raced. Horse #5 from race #1 could be faster than the first place finishers in all other 4 races. Rank the top 5 fastest times. Odds are that they were not all from the same race. Maybe you race them one more time against each other to verify your ranking technique (and in the good spirit of a playoff.) This brings the total to 6. 5 (or 6) is a great, pat answer if you know all of the particulars. Unfortunately, most programming in the world of finance wants to make sure nothing is being missed. The interviewer wants to see how you think and how you code. If you had a timer, yeah, 5 races are what you need. Sort all 25 horses by time and voila, you have 1, 2, and 3. However, horses (loans, retirement funds, Investments) will perform differently over time, distance, endurance, phase of the moon, etc. The interviewer wants to hear the deep answer to see your thought process. When you are dealing in operations that take milliseconds, extra loops in order to be thorough are not a bad thing. How about 11 races - 5 horses in Race 1. Best 3 face horses 6 & 7. Best 3 face horses 8 & 9. Best 3 face horses 10 & 11. Rinse and repeat. Or 12 races - first round - 5 races of 5. (W)in, (P)lace, and (S)how in each go to second round (15 horses). second round - 3 races of 5. W, P, & S in each go to third round (9 horses). third round - a race of 5 and a race of four. W, P, & S in each go to fourth round (6 horses). fourth round - race 1 - W, P, & S from round 3, race 1 and W & P from round 3, race 2 fourth round - race 2 - W, P, & S from round 4, race 1 and S from round 3, race 2 Not pretty, but definite. I think 5 is the correct answer. Why?: The first requirement is to get the minimum races (no tournament). Secondly, It does not dictate how to get the time. It only conditions 5 horses per race. Which mean 25 / 5 = 5 races. Now, How to time: the timer can help to get the individual hoese race time. These days the time can be measures upto 0.000 (there fractions) which is good enough. Aslo there is no condtion to handle exceptions, so we can skip any exception. 12 RACES ARE REQUIRED -------------------------------------- In the worst case scenario the 'best three' can be from a single team of 5 horses. So 5 races in round one. Chose all the first three of each of the 5 races. 3 races of all the 15 horses which were the 3 winners of the first round. Chose the 9 horses which were winners in round two and have 2 races for the 9 winners[ 5 & 4 horses] you get 6 winners. 1 race of 5 horses, out of the 6 round three winners, keeping one standby 1 race of 4 horses of round four winners with the standby. This will give you the best 3 horses out of 25 So you need to have 5+3+2+1+1 = 12 races in order to get the best three horses. Answer 12 races required. Sometimes the 2nd and/or 3rd best athlete do not get selected if they are teamed in a race along with the best athlete. dynamitemike's answer is the one. A timer could be considered but the problem would be pointless if you had a time. Run 5 races, let's say, Hij denoting the j-th rose in the i-th race, 1 <= i <= 5, 1 <= j <= 5. Eliminate the last two, since there will be three or more horses faster than them for sure. We are left with 15 horses. Run a 6th race with the Hi1 (the 1st placed horses). Suppose the results are Ha1, Hb1, Hc1, Hd1 and He1. The fastest horse in this race (Ha1) is the fastest horse of them all. The last two (Hd1 and He1) can also be eliminated because there will be three or more horses faster than them for sure (at least the top 3 of the 6th race). At this point, we have 12 horses to consider. But the 2nd and 3rd places horses in the preliminary races of the two worst placed horses (Hd1, He1) in the 6th races (Hd2, Hd3, He2, He3) can also be eliminated since there will be at least three horses faster than them. We have only 8 horses left. What about the 2nd and 3rd places horses in the preliminary race of the 3rd placed horse (Hc1) of the 6th race? There will be at least three horses faster than them (Ha1, Hb1 and Hc1). They can be eliminated. We have 6 horses left. Following the same reasoning, the 3rd placed horse in the preliminary race of the 2nd placed horse (Hb1) of the 6th race can be eliminated because there will be at least three horses faster (Ha1, Hb1 and Hb2). We have 5 horses left, namely Ha2, Ha3, Hb1, Hb2 and Hc1. These horses will run in the 7th race and the top 2 will join Ha1 and they are the top 3 horses among the 25 initial. Note that the maximum numbers of races required is MAX = 1 + (H - R)/(R - T), if you have H horses, if you can use R horses per race and if you want the top T horses among all H. For H = 25, R = 5 and T = 3, MAX = 11 races. You get to this result simply through successive races eliminating the last two (R - T) and adding the same number of horses until all of them have raced. It is an exhaustive "brute force" approach. If we were looking for the fastest horse and could only use 2 horses at a race, the problem would actually be: "what is the minimum number of comparisons required to find the maximum value of an unordered set of N values?" A brute force approach would require N - 1 comparisons. In addition, another problem variation: given N^2 horses, if you can use N horses per race, then you only need N+1 races to find the fastest horse. Show more responses Do I have resource to metter the time of each horse in each race? Assuming I have it. So I need only 5 races. Assuming I don't have it, I need to understand I cannot eliminate the second and third horses, because they could be faster than the fisrt horse of another race. Assuming either I can have more than one race for each horse with the same performance, after the first five races I eliminate 10 horses. After the next 3 races, I eliminate more 6 horses. Now I have 8 races and 9 horses. For the next 2 races I eliminate more 3 horses (2 in the 1st and 1 in the 2nd). Now I have 10 races and 6 horses. In the 11th race with 5 horses I eliminate more 2 horses, having 11 races and 4 horses. In the last 12th race I find the better 3 horses in order. So, in my opinion I need 12 races to find the best 3 horses, assuming I don't have resource to metter each horse time in a race and assuming each horse run always the same lap time. dynamitemike & Isac Costa nailed it. Seven races are needed without using a timer. You can only eliminate two horses a race maximum. Fastest 3 out of 5. The goal is to eliminate 22 horses (25 down to 3). So 11 is the minimum number of races needed. You have to assume that it's possible each race to actually have the fastest three horses in the bunch. So eliminating more than two horses in any race means you are assuming something that may not be true. Another angle on this. Everyone gets the part about 5 races with 5 horses each. The key is to realize that it is possible that any of those 5 races could contain 0, 1, 2 or 3 of the best 3. The sixth race between the five heat winners can eliminate the two slowest ones. The seventh race is key. After six races, we already know who the fastest horse is, so you only need determine #2 and #3. The fastest horse rests and eats some oats. + Take 2nd and 3rd place finishers from the heat that was won by the fastest horse + Take 2nd place finisher from the heat won by the second fastest horse in the sixth race + Now race these three along with 2nd and 3rd place finishers from the second race and pick the two fastest horses to be #2 and #3. 1 race. You already have the 3 fastest. Win, place, show. No one said i couldn't rerun the same race. The answer has to be 12 For the reasons stated above, and the fact that horses do not race in a vacuum. They are influnced by the other horses in the race, things like drafting, setting the pace. There are frontrunners, and closers. A horse may only run fast enough to win. If they did run in a vacuum, 5 races and a stopwatch would be all you would need - I didn't see that a stopwatch was supplied in the question. None. The way the question is phrased, it doesn't even tell you what the requirement is. 6 is the answer. 1. Race 5 horses 2. Eliminate slowest 4 3. Add 4 horses, race again 4. Repeat steps 2 and 3 until all horses have competed, the winner of the 6th race is the fastest horse. This assumes that: a) the horses will performance identically in each race b) timing devices are not available Santosh K. Rao has the right idea and so the answer is 12. However, the only problem I have with his suggestion is that in the second last step, sitting out the one horse (because you can run only 5 at a time) will give it a competitive advantage as it has raced one less race than the winning 3 horses that it is about to compete against. But this aside, 12 is the right answer. If a timer is available then only 5 races. But if a timer is not available then 8 races. Divide the horses into 5 groups (Group A, B, C D and E). Races 1 to 5 are intra-group races. Race 6::: The fastest horse from each group runs this race. The winner of this race gets the gold medal. Race 7::: 4 horses from race 6 will remain the same. However, replace the winner of race 6 with the next-fastest horse in the same group as the winner of race 6 (we will have this information from the results of races 1-5). The winner of this race gets the silver medal. Race 8::: Same logic as race 7. Replace the winner of race 7 with the next fastest horse of the same group. The winner of this race gets the bronze medal. Show more responses I thought the answer was 9... then I read Debarshi's post... 8 is the right number. Nice I believe Issc's answer is correct and I will make it more clear by drawing a simple diagram. Lets map out the 25 horses on a grid: 1 2 3 4 5 ------------ 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 Above is the grid, the 1-5th places for 5 races are listed as columns. The 6th race, which races the 1st place of each horse, is listed as a row at the very top. So now we have a ranking for each column. From here alone, we see that the fastest horse is in the top left corner: 1 Then, in addition, we will add the possible contenders for 2nd place: 1 2 1 Finally, we will add the contenders for 3rd place: 1 2 3 1 2 1 Every other number not in this triangle are not contenders for the top 3, and are thus eliminated. Knowing that the top left "1" is already the fastest, we put the other 5 horses into the 7th race to determine the 2nd and 3rd place. Hope this helps. Apparently I can't edit my post; I made a typo above, let me retype the wrong portion: From here alone, we see that the fastest horse is in the top left corner: 1 Then, in addition, we will add the possible contenders for 2nd place: 1 1 2 Finally, we will add the contenders for 3rd place: 1 1 1 2 2 3 Every other number not in this triangle are not contenders for the top 3, and are thus eliminated. Knowing that the top left "1" is already the fastest, we put the other 5 horses into the 7th race to determine the 2nd and 3rd place. Hope this helps. This question is about three things: (1) recognizing path dependence (performance is based on the environment) (2) evaluating your ability to reason critically (3) your ability to to question assumptions (do we have a stop watch? does it matter?) There is no "right" answer to this question, they want to see you come to the conclusion that the right answer depends on your assumptions and what you're trying to measure. If you have race times and assume path independence the answer is 5. If you have race times and assume the paths are not independent it's 8-ish. No race times + path independence is 11. Basically they're asking you how many scenarios you should use to price an exotic derivative, but putting it into a context where you can't fall back on "stock" answer(s). Definitely 7. Top 3 in each race (a,b,c,d,e) are in play after round 1, 15 horses. Five winners from round one race. This gives you the undisputed top horse (let's call this horse a1) and moving on to the next round are b1, c1 (2nd and 3rd place in race 6) and a2,a3,b2,b3,c2,c3 for a total of 9 horses. First overall is already confirmed so we only need to determine 2nd and 3rd places now, so our pool is 8. We then eliminate c2 and c3 because the best c1 could do is 3rd place. We also eliminate b3 since the best b2 can be is 3rd place. Now we have 6 horses remaining. Only the bottom 5 run in the last race and the top two placers fill out our top 3. All of this assumes these horses run the same speed each race, of course. If I have a way to time them, 5 races is the minimum. If I do not, then the answer is 7 races. We take the winner from each of the first 5 runs. The ones who place 4th & 5th in this race not only disqualifies them from being top 3, but also disqualifies everyone who ran with them in their first run. The 3rd place finisher in this race is the only possible placer from his first run. The second place finisher in this race is the possible second place overall and the one who took second in that race has the possibility of coming in third overall. The first place finisher from the scond run is first overall and does not need to race again, but the second and third place from that horse's first race might get 2nd & 3rd overall so they need to run again. After you figure who needs to run again, there are only 5 of them so only one race is needed to determine 2nd & 3rd place overall... these horses ar the second & third place from the first run with the first place overall winner. The horse who placed second in their second run and the horse who was second in THAT horse's first run, and the horse who placed third in the second run. Another way of putting it. Assume no timer: 1) 5 races: run all horses. We'll call the races heats A, B ,C, D, E (eliminate last 2 in each race) 2) 1 race: run all 5 of the 1st place horses (eliminate last 2) 3) 1 race: assume the fastest overall horse was from heat A (we'll cal it A1), the 2nd fastest was from heat B (we'll call it B1), and the 3rd fastest was from heat C (we'll call it C1). the only possible combinations of fastest horses is: -A1, B1, C1 -A1, B1, A2 -A1, B1, B2 -A1, A2, B1 -A1, A2, A3 Therefore A1 is the fastest horse. So you only need to race the remaining 5 horses. Conclusion: 7 races are necessary. Assuming we know the second and third place winners and not just the first place winners of the respective races, then 7 is the minimum amount of races required, as theparadox put it. If we only know the first place winners, then we need probably around 10. The correct answer has been posted. It's 11 races, and Mark's reasoning from Jan 11 is correct: In each race you can eliminate at most 2 horses. Can't beat logic! 12 is undoubtably the correct answer here. Just by following pure simple logic and mathematics. First you need to determine a model for the iteration: Take 1 heat of 5 horses. Suppose the top three finishers in this heat are the fastest three out of any of the other 4 heats (We're working with a total of 5 heats, each consisting of 5 horses). This 1st heat will yield the fastest three horses. The 4th horse does not matter, and never matters. Even if the 4th horse is faster than the 1st place finisher in the 2nd heat, you are still left with the top 3 horses in the 1st heat. The 4th place finisher is irrelevant in any heat. Now assume you have the slowest 5 horses in the 1st heat. Then no matter what, these horses will be weeded out in future heats against all the top three finishers of the other heats. So what we conclude here is that the top three horses in each heat are the only relevant horses considering the fact that we are looking for the fastest three horses. Once we know this, the problem is simply an iteration. Here it is: Run 5 races, select the top 3 of each heat. (We are left with 5 x 3 = 15 horses) Run 3 races, select the top 3 of each heat. (We are left with 3 x 3 = 9 horses) Run 2 races (one with 5 horses, one with 4 horses), select the top 3 of each heat. (We are left with 2 x 3 = 6 horses) Run 1 race, select the top 3 of this heat. One horse sat out during this race and must be tested against the top 3. (We are left with 4 horses) Run 1 race, select the top 3 of this heat. These are the 3 fastest horses. It took 12 races to determine this. Show more responses Most of you are making this harder than it has to be. You run five races and time each horse once. You compare their individual times (regardless of who they raced against directly )and pick the top three. 7 is correct. if you label the horses 1-25 and create groups of 1-5, 5-10, etc for the first 5 races and for simplicity the horses finish in numerical sequence for each heat. So horse 1, 6, 11, 16, & 21 won their heats. Race the winners and they also finish sequencially so horse #1 wins and it gets the gold. That means horse 11 is best case 3rd fasted and 12-25 are eliminated. Now the 2nd fasted horse can only be #2 or #6. If it's #2 then the 3rd fasted can only be #3 or #6 so that eliminates #4 & #5. Howver, if #6 is the 2nd fastest then the 3rd fastest can only be #2, #7, or #11. This eliminates #8, #9, & #10. After the conceptional eliminations, we are left with #2, #3, #6, #7, #11 for the seventh race. The top 2 join #1 in the winner's circle. Answer is 11 as posted multiple times... no assumptions should be made (timer, won a heat then you're faster than others etc.) In this case, each race of 5 horses would eliminate 2 from contention as being top 3. In order to eliminate 22 horses (25 - top 3), you would need 11 races. the question is not fully defined! instantaneous velocity? over a long or short race? do we include a running start? on that day or on average during the horses' lives? on what planet? what surface? what weather? with or without drugs? with or without a rider? what weight rider? how experienced? saddled? bridled? etc, etc, etc........... 7 is the right answer. Guys, who suggests 11 and 12 - please, try to understand the explanation first. I tried, and I got it finally. let's assume horses 1, 2 and 3 are the fastest. But we don't know it. 1) first 5 races 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 let's assume horses 4, 5, 9, 10, 14, 15, 19, 20, 24 and 25 are the slowest. They are eliminated first. We established already that first three horses in each race stay, cause they could be the fastest of all. 2) 6th race - we take only the fastest horses from all races, let's assume these are 1 6 11 16 21 1st horse we will make the fastest. Let's put it in the pocket. Let's assume the horses came in the order the are standing. First 1, second 6, third 11, forth 16, fifth 21. 3) the 7th race is the key!!! It's the most complicated race to organize. let's see: in this race we don't take the horses number 1(we know it's the fastest of all), we don't take the horses 17, 18, 22 and 23 - they are slower than the slowest horses 16 and 21. Horses number 12 and 13 are slower than 11, and logically, than 6 and 1. The same with the horse number 8: we know already that it is slower than 6, 7, and 1. The only horses which can possibly be faster than the 6 and 11 - are the horses number 2, 3 and 7. So, the 7th race is between 2 3 6 7 11 the first two in this race - are the second and third fastest of all. Looks like I can add a new perspective, the answer is 6. This is based on the wording of the question where they ask for the minimum number of races required to find out. They don't ask for the minimum number guaranteed to find out. So.... you run one race, and then you run the third place finisher in that race in the next five races against 4 new horses in each race. If the original third place finisher wins the next 5 races you have your answer in the minimum number of races. I don't want to guess the odds of this very remote scenario taking place but it is the minimum. Of course the "outside the box" answers might be passable, I especially like, "None. If I already chose the fastest three horses, they are the fastest." But mathematically, it's 7, assuming the horses always run at the same speed. Natalya did probably the best job explaining it, but I'll try a different tack (ha!). I encourage you to write this down and cross out the eliminated horses. Assume the 25 horses are named A-Y. Race 1: A B C D E Race 2: F G H I J Race 3: K L M N O Race 4: P Q R S T Race 5: U V W X Y So far, yes, the people saying you can only eliminate 2 horses per race are correct. We've only eliminated the slowest two in each heat thus far. Assume the left-most was the fastest and the right-most was the slowest. Now we race the winners: Race 6: A F K P U Now we've added a significant amount of information. Not only can we eliminate P and U, but we eliminate all of the horses that they defeated. We can also eliminate all of the horses that K defeated, but we can't eliminate K itself. For each of those horses, at least A, F, and K are faster. Lastly, we can also eliminate H, because we know for a fact that at least A, F, and G are faster. We know A is the absolute fastest, so that leaves: Race 7: B C F G K The winner and runner up have to be the second and third fastest, respectively. Let's look at this question backwards how many horses can be eliminated in each heat. Heats 1-5 you eliminate all horses that did not finish in 1-3 place. Heat 6 you run top horse from heats 1-5. You can eliminate three horses from the 4th and 5th place horses heats, plus the 2nd and 3rd place horses in the heat 6 3rd place finishers original heat, plus the 3rd place finisher in the heat 6 2nd place finishers original heat. The 6th race eliminates 9 horses. This leaves the horse that finished 1st & 1st who is in for sure and the following 5 horses to race again in heat 7: The two remaining horses from the winner's first heat, the heat 6 2nd place finisher and the horse that finished second to him in their first heat and the third place finisher in heat 6. Top two are combined with the 1st 1st horse for the answer. The Right Answer is SEVEN!! Think of the question "How many people defeated a Horse?" After the first round (which everyone agrees is a round of 5 races of 5 horses each) we get the following matrix ---------------------------- AFTER FIVE RACES ---------------------------- 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 Now when we play all the Winners of these races in one match (The First Row) interestingly these numbers change to the following. Note that if your team's Winner loses against one person (stands second) your entire team shifts one place down (The entire column's number increases by one). If your team member loses against 2 people then your entire team shifts down two places. (Increases by 2) ---------------------------- AFTER SIXTH RACE ---------------------------- 0 1 2 3 4 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 Now if a horse has been defeated more than 3 or more times that clearly indicates that there are at least 3 horses better than it and hence you that particular horse is eliminated That leaves us with the following. 0 1 2 1 2 2 You now need only one more race to decide who is the second and third. You already have found your Ace Horse ;) I could like to choose 8 races. race 1: A B C D E race 2: F G H I J race 3: K L M N O race 4: P Q R S T race 5: U V W X Y This is much same as others to drop the last 2 horses in each race. Drop: D E I J N O S T X Y Pick the fastest horses on race 1 to 5 race 6: A F K P U After race 6 I could drop 8 horses, Drop: H M P Q R U V W Remaining: A B C F G K L As A is the fastest from race 6, I could states H and M won't be the top 3 horses and A is the fastest. Combination of top 3 should be (AFK), (ABC), (AFG), (AKL), (ABF) and (ABK). Thus, my race 7 is to test if C is the third fastest of the horses above. race7: C F G K L If C is the fastest then I am done. If not, drop C. race8: B F G K L DONE ~~~~ Show more responses The answer is definitely 7. Read here for a very detailed and easy to understand explanation: http://www.programmerinterview.com/index.php/puzzles/25-horses-3-fastest-5-races-puzzle/ Hi. If all 3 fastest horses were in the same group for the initial race and the 2nd place horse from that group won race 7, the 3rd place horse could not be eliminated without racing. The answer is that 7 races are likely needed, but an 8th race might be needed. The chance of needing an 8th race is 3 and 1/3 percent. "daved18" You are the Winner!!!!!!! Using only the information given and nothing else you have correctly answered the question. That being said I really enjoyed reading all the other perspectives given. It really shows how many approaches there are to answering a question without being able to ask any. You need to make a determination of whether or not a horse's time is affected by the horses it races against. If not, the answer is of course 5. If so, then you can start looking at the other options listed above. 10 - The correct answer can only be 10. (Note: those who answered 12 are close, but they fail to conclude that, by racing the 3rd place horses together in separate heats, they can eliminate one unnecessary race.) By the way, the question asks for the fastest 3 horses – so we can assume nothing less than that the results must be exact. Some assumptions can be made: 1. The 3rd fastest horse in each race (other than those races of only 3rd place horses), could be the 3rd fastest overall , so it can never be fully eliminated. It is possible that it was forced to run all of its races against the fastest two horses. 2. The 3rd fastest horse in each race can never be the 1st or 2nd fastest horse, so you can eliminate all 3rd place horses by racing them together. Only the fastest of these 3rd place horses could ever be the third fastest overall - so in these races, only the fastest needs to be promoted. First heat (5 races – total = 5): Take the top 2 horses from each race and put them aside for the third heat (10 horses total). Second heat (1 race – total = 6): Race all 3rd place horses from the first heat. Only the fastest horse in this heat needs to be promoted. Third heat (2 races – total = 8) Race the 1st and 2nd place horses from the first heat. The top 3 horses from each race gets promoted (6 horses total). Fourth heat (1 race – total = 9) Race the two 3rd place horses from the third heat and the winner of the second heat (all 3rd place horses). The fastest of these horses could be the overall 3rd fastest, but it is the only one needs to get promoted. Fifth heat (1 race – total = 10) The two fastest horses from each race in the third heat, along with the winner of the fourth heat. Top three horses in this heat are the fastest three overall. Again, the answer is 10 – and it can only ever be 10. I made a mistake - the answer is 9. If you race the 2nd place horses from the first heat together (in the second heat), the winner of this race could ever be the 2nd or 3rd place overall if it raced against the 1st place horse in the first heat. But because only one of these 2nd place horses could have raved against the fastest horse overall, all others in this race could never be even 3rd place overall, since it would have lost its first heat to, at best, the 2nd place horse overall and then lost the second heat as well. I do apologize for not catching this in my first post. Again – the answer is 9. debarshi nailed it. 8 races. it also means that the general answer, where: n = number of horses r = maximum number in a race p = number of places needed is , in APL, p + ? n÷r 7 races is the correct answer I think 9 races will solve the problem... 1) 5 races to get locally top 5 horses 2) In race #6, I will race the 5 winners from 1st round. 3) In race #7, I'll race the 2nd place holders from round 1 with each other. 4) In race #8, I'll race the 3rd place holders from round 1 with each other. 5) Now, race the top 3 from race #6, with the best horse from race #7 and race #8 That's it ! The top 3 of this 9th race are your 3 fastest horses. Explanation: From first 6 races, you get the undisputed champion Assuming that you raced the actual 3 fastest horses together in one of the first 5 rounds, you give chance for the second fastest horse in race #7. Again, assuming the previous worst case scenario, you grant the third fastest horse race #8 And finally, you race the top 3 from race #6 with top 1 from race #7 and top 1 from race #8. If the ideal case turns out, where first 5 races gave you the actual fastest horses, they would naturally win the race #9 (since you kept the top 3 amongst them) So the answer is 0. No races are actually required to do as the question asks, which is to pick the 3 fastest horses. Had the question been asked to provide the minimum number of races to PROVE you have picked the 3 fastest horses then I believe the answer is what ever you overthinkers know the answer to be. Show more responses Travis took my answer. Good answer by the way Travis. It is designed to see your thought process. Do you have a tendency to over think or over analyze a problem? First we need some assumptions. Let's say the horses perform the same in different races, and we are looking for the minimum number of race to determine the fastest three. 1) If we got a timer, the answer is five, obviously. 2) I we did not have a timer and could only record the standing of horses, the number is 7. Firstly, 5 races will cover all 25 horses and give us the champion of each group. 6th race is between the 1st horses of 5 groups, and we name the groups A, B, C, D, E, according to the standing of this 6th race. The 2nd and 3rd horses of group A, and 1st and 2nd horses of group B, also with the 1st horse in group C will attend the 7th race. The top two of 7th race and 1st horse of group A give us the fastest 3. See http://math.stackexchange.com/a/746801/6876 The answer is: You need 7 races. 7 check career cup book for explanation 5 races. you just need a stopwatch!? Ans: 8 After 5 races you have 5 sorted lists. Now you have to merge them using a 5-way merge. First 5-way compare: race 6 Second 5-way compare: race 7 Third 5-way compare: race 8 5 races of 5 will yield 15 new candidates by picking the top three each time, 4 and 5 are eliminated 3 races of 5 will yield 9 new candidates by picking the top 3 each time, 4 and 5 are eliminated 2 more races, one of 5 and another with 4 will yield 6 new candidates by picking the top 3. 2 more races of 3 will yield 4 more candidate picking the top 2 one more race will yield the 3 top horses. 5 + 3 + 2 + 2 = 12 races will yield the absolute 3 best horses. Show more responses 25 horses 5 groups of 5 horses choose the first place horse from each group have have them race From this race we gain information ---The 1st place can win in the other group, but the same does not go for the other top two horses. ---2nd place can beat the horses in 3rd place's group and the other groups, but it's uncertain if 2nd place can beat horses in 1st place's group ---it is uncertain that 3rd place can beat horses in 1st and 2nd place's groups, but can beat horses in the other groups 2 place races the horse in 1st places groups. whichever horse wins is able to beat horse in all the other groups except the original winner of the top 5 horses 3 place races horses in 2 place's group, whichever horse wins is able to beat horses 3 place's group and 2nd places group. --That same horse faces 1st places group in 1st place's group, whichever horse wins is able to beat horses in 1,2,3 places group but not the original 1st place horse. 9 races in total and you have the top 3 horses. 5 Races It says fastest horses, NOT the ones that win the race. In 5 races, you will know ALL of the horses time around the track. 1: ABCDE : Keep fastest horse out of race, ex. A time x secs 2: FGHIJ : Keep fastest horse out of race, ex. F time x secs 3: KLMNO : Keep fastest horse out of race, ex. K time x secs 4: PQRST : Keep fastest horse out of race, ex. P time x secs 5: UVWXY : Keep fastest horse out of race, ex. U time x secs Out of the 5 fastest horses, one winner from each race, pick the top 3 fastest horses out of A F K P U: ex. A K U 5 Races Showing my work... 5 Races: 1) ABCDE : Keep top 3 fastest lap times from ABCDE ex. ABC 2) FGHIJ : Keep top 3 fastest lap times from ABC FGHIJ ex. ABF 3) KLMNO : Keep top 3 fastest lap times from ABF KLMNO ex. AFK 4) PQRST : Keep top 3 fastest lap times from AFK PQRST ex. APQ 5) UVWXY : Keep top 3 fastest lap times from APQ UVWXY ex. APU The top 3 fastest horses would be APU One or more comments have been removed. |
Software Engineer II at Redbox was asked...
How many people flew out of Chicago last year? 66 AnswersYou are obviously not supposed to know the answer to this question. It is more of a way to gauge how you would determine the scope of a problem and work your way from no knowledge to being able to put together a solution to figure it out. Actually the answer is zero. Plans fly, people don't. oops - typo - Planes fly, people don't Show more responses Roughly as many who flew into Chicago. My estimate off the top of my head is 30 planes/hr x 24 hr/day x 365 days/yr x 180 people/plane (avg) = 47M and change. Actual for 2014, Domestic and International, is 70M. This is Passenger Volume so # leaving is 35M. Humans don't fly. Considering that humans fly after sitting in plane, I say it is 1 million. To check it, verify the database yourself. None, . Airplanes fly people ride People can not fly, however planes can. I don't know, but if you gave me some time on the internet, I could find out Chicago is one of the busiest airports. There maybe 1000 flights flying out everyday. 50 ppl in each flight. So 50,000 none. people can't fly I believe the answer is "I don't know" (Unless you do know.) There is a growing idea that businesses need people who are willing to admit that they don't know the answer to something and will admit that without hesitation or making something up. If you aren't comfortable just leaving it at "I don't know" you could explain how you would go about finding the answer. Show more responses What is the relevance of the question to the job being applied for? Under their own power: zero. via airplane: 139,345,887.5 people. Just one...but he was sucked into an airplane's engine in-flight and no one will ever know how he accomplished human flight. Half of the people who had tickets. Chicago weather sucks!!! :) All of them did, they couldn't find any good movies to rent from RedBox. None unless "Chicagoans" have wings. Flying's the easy part. Anything can fly if you put a big enough engine on it. So, maybe 1 or 2? Doubt any are still alive, though. The landing is the tricky part. Unless I missed out on that Fox News Special. I'd have to give a resounding "ZERO!" People don't fly! Definitely not all of them... I have no idea. I guess the interview thing to say would be "I can find out for you though" but honestly, isn't my time best spent on something else? Show more responses This is not an oddball question at all but a classic in job interviews for aspiring consultants. The question is testing your problem solving skills rather than your knowledge and the answer is of no real importance as long as your way of getting to it is conclusive. The obvious "people don't fly, planes do" may be good for a quick laugh but unless you follow up with a real answer, you're out. Since the question was from an interview for a software engineer, the right answer is "give me your name, email address, and office extension and we'll open a help ticket"; then do not open a help ticket and forget the call ever happened If it's February, all of them. I don't know, but if it's necessary for me to know this, I can certainly find out. Why is this important for me to know? 1.5 as many that flew in Zero. People cannot fly. I am not sure that data exists because of private aircraft also coming and going. If the FAA or airport authorities have that data, combined with passenger data, I could probably research it and find out. Do parachutist count too? As many as those who flew in Chicago Show more responses Well, don't ask the airlines. No one knows what the hell's going on at ORD I'd guess: 4 minute FAA separation mandate 737 the most common = 120 ppl Hours of operation = 6am-12pm (abatement) 365 days 6 runways (double triangle for busy airports) 6 runways x ((18h x 60min/hr)/4min per plane) x 120 ppl x 365 days = 70.956M ppl total. As others said, half those are flying out, so 35.478M ppl But I'm an aviation nut, so that's more than the average bear. Google for 1st estimate and then dig in deeper if this would be a significant information to a Project. Do witches count as people? Oh wait, witches don't fly. Brooms fly. The same number of boarding passes given out Why the crap would we have to estimate it when the information would be available from secondary sources....google it Was the Birdman movie set in Chicago? Zero. As many as had reached to Chicago through airplanes. Show more responses Everyone who boarded a departing flight. For the folks doing the math: there's more than one airport in Chicago. Adjust accordingly. None, people are incapable of flying. None people are incapable of flying. Only one, I can even tell the name to you on my first day. Yea, none. The calculation is a bit tricky, if you really want to know it: It is relatively proportional to the number of Bags (luggage) carried out of Chicago. Please provide me the database, I would come up with an answer. Note: For precise number you need to also include the handbag. Regards, Abhi Besides Superman probably nobody else. None. People can't fly. Zero. People can't fly...no wings. Show more responses Zero. People can't fly...no wings People can't fly as many people who booked flights through Chicago. None. Technically, there are no airports "in" Chicago. They're in the suburbs. One guy : RKELLY. He is the only human being who believes he can fly. Approximately the same number that flew in "The number of people who flew out of Chicago" is a true answer, albeit a tautological one. It requires no specifics and takes into account not only the zero ("people don't fly") answer but many of the other responses above as well, some of which may be off a few degrees (for example, even people who had boarding passes and got on board might not actually have completed their flight, and not everyone who flies in flies out, etc.). This tautological answer, though, because the context is an interview, is likely to be perceived as flip and would probably get the answerer lumped in with the people who answer zero—the "if the person says zero, he or she is automatically out of the running" scenario mentioned above. Although to use a tautology or to answer "zero" probably won't succeed if done directly, such things can be embedded within one or more linguistic frames, including hypotheticals—ifs. ("If you wanted a tautological answer, I could say XYZ" or "Assuming you're not being literal about people flying and you're interested in finding out ABC about me, then XYZ.") Another way of approaching the question—a way that in fact is a demonstration of your strategy for relating to questions, an answer in itself—is to ask a question in return (such as one that probes for more detail—"Does that include private planes as well as commercial carriers, and blimps, helicopters, and so on?"), which invisibly begins to shift the dynamic of the interview (now you're the one asking the questions). Perhaps a better-quality question than asking for details about the content of the question would be to notch it up a level and ask the questioner something that seeks to discern his or her underlying purpose in asking the question. By doing so, the sterile, impersonal nature of the question is transcended and a personal exchange comes into play between interviewer and interviewee-cum-interviewer. The question you invent is up to you—how brilliant can you be at having the other person be brilliant? No one flew out of Chicago last year, because people do not have wings. No one. People do not have wings. I would google it. Show more responses Those people flew out of chicago who have bought air-plane ticket. They all did. With Air Canada, twice as many as their luggage. One or more comments have been removed. |
Suppose you had eight identical balls. One of them is slightly heavier and you are given a balance scale . What's the fewest number of times you have to use the scale to find the heavier ball? 60 Answers3 times. (2^3 = 8) Two. Split into three groups of three, three, and two. weigh the two groups of three against each other. If equal, weigh the group of two to find the heavier. If one group of three is heavier pick two of the three and compare them to find the heaviest. Brian - this would be correct if you in fact were using a weighing scale, and not a balance scale. The ability to weigh one group against another with a balance scale allows Marty's answer to be a correct answer. Although - the question as worded provides a loophole. If it had been worded as "What's the fewest number of times you have to use the scale to CONSISTENTLY find the heavier ball", then Marty's answer would be the only correct answer. However, it is possible that you could get lucky and find the heavier ball in the first comparison. Therefore, the answer to the question as stated, is ONE. Show more responses This question is from the book "How to move Mt Fuji".... Marty has already got the right answer. Actually Bill, by your interpretation of the question the answer is zero, because you could just pick a ball at random. If you get lucky, then you've found the heaviest ball without using the scale at all, thus the least possible amount of times using the scale would be zero. The answer is 2, as @Marty mentioned. cuz its the worst case scenario which u have to consider, otherwise as @woctaog mentioned it can be zero, u just got lucky picking the first ball.... None- weigh them in your hands. Assuming that the balls cannot be discerned by physical touch, the answer is 3. You first divide the balls in two groups of 4, weigh, and discard the lighter pile. You do the same with the 4 remaining, dividing into two groups of 2, weighing, and discarding the lighter pile. Then you weigh the two remaining balls, and the heavier one is evident. 2 3a+3b+2 = 8 if wt(3a)==wt(3b) then compare the remaining 2 to find the heaviest if wt(3a) !== wt(3b) then ignore group of 2 discard lighter group of 3 divide the remaining group of 3 into 2+1 weigh those 2 If == the remaing 1 is the heaviest if !== the heaviest will be on the scale With the systematic approach, the answer is 3. But, if you randomly choose 2 balls and weigh them, and by coincidence one of these two is the heavier ball, then the fewest number of times you'd have to use the scale is 1. Although the real question is: are the balls truly identical if one is heavier than the rest? just once. Say you are lucky and pick the heavy ball. One use of the scale will reveal your lucky choice so once, or the creative answer zero if you allow for weighing by hand Without judging by hand: Put 4 balls on one side, and 4 on the other. Take the heavier group and divide again, put 2 balls on one side, and 2 on the other. Take the 2 that were heavier, and put one on each side. You've now found the heaviest ball. This is using the scale 3 times, and will always find the right ball. Show more responses None. They are identical. None is heavier. 2 weighings to find the slightly heavier ball. Step 1. compare 2 groups of three balls. Case 1. if they are both equal in weight, compare the last 2 balls - one will be heavier. case 2. If either group of 3 balls is heavier, take 2 balls from the heavier side. compare 1 ball against the 2nd from the heavy group result 1. if one ball is heavier than the other, you have found the slightly heavier ball. result 2. if both balls are equal weight, the 3rd ball is the slightly heavier ball. Easy Shmeezi Fewest - get lucky and pick the heaviest one. But wait! How would you know it is the heaviest one by just weighing one ball? Your logic is flawed. Two groups of four. Split heavier one, weigh. Split heavier one, weigh. 3 times. i think its 3. i would take it like this OOOO OOOO then OO OO then OO problem solved. i do this everyday. bye. praise be to allah. thats it. It's 2. Period. If you can't figure it out look it up online or in "How Would You Move Mount Fuji" (like somebody else said). This is one of the most basic brainteasers you could be asked in an interview. The answer is 2. 1) Divide the balls into 3 groups. 2 piles with 3 balls each, 1 pile with 2 balls. 2) Weigh the 2 piles of 3 balls. If both piles are the same weight, discard all 6 and weigh the last 2 to find the heavier one. 3) If 1 pile of 3 is heavier than the other, discard the lighter pile and the pile of 2 balls. Weigh 2 of the remaining 3 balls from the heavier pile. If both of the weighed balls are equal, the last ball is the heavier one. 2=if all the balls are identical and you pick up the first...weigh it and the second one is lighter or heavier then you've found the heavier ball in the least amount of attempts. 1=if all the balls are identical and you pick up the first...balance it and the second one is lighter or heavier then you've found the heavier ball in the least amount of attempts. Amy is 100% correct for the following reason: everyone (except Amy) is solving the theoretical problem. The practical side of the problem - notwithstanding jimwilliams57's brilliant observation that if one weighs more than the others IT IS NOT IDENTICAL (would have loved to see the interviewer's face on that one) - in order to 'weigh' them on a scale, one has to pick them up, therefore, you will immediately detect the heavier one without weighing: pick-up three and three ... no difference, no need to weight. Pick-up the remaining two to determine the heavier one. Steve First off, take yourself through the process visually and forget square roots, that doesnt apply here and here is why: The question is the Minimum, not the MAXIMUM. BTW, the max would be 7 ( 8-1); you are comparing 2 objects, so 1 ball is eliminated automatically in the first step. Anyway, you have a fulcrom of which you are placing 2 of 8 objects on each end. If by chance you pick the slightly heavier object as one of the two balls, you have in fact, found the slightly heavier one in the first round... btw dont be a smartass with your interviewer, he is looking for smarts not smarmy;) Show more responses Respectfully, the folks who are answering "3" are mathematically modeling the nature of the balance incorrectly. Performing a measurement on a balance scale is not binary. It is trinary. Each measurement gives you one of three responses: The left is heavier, the right is heavier, or they are equal. So while you do need three binary bits to specify a number from one to eight, you need only two TRINARY-DIGITS Formally, you want the smallest value of n such that 3^n >= 8. The answer is 2. Note that you could add a ninth ball, and still, you'd only need to make two measurements. Of course, the smarty pants answer would be one. Just pick two balls at random and be lucky to have chosen the heavy one. But you're not guaranteed to be able to do it in just one measurement. English isn't my mother tongue... What is a balance scale? If looking up on Google, I find some devices with two bowls on a bar bearing in the center. Hence, the answer is once (if I'm luck enough to select the heavier ball in teh first measurement) If a balance scale allows to measure only one ball at a time, then it would take two measurements, unless you'd have more information on the weight, which is not listed here, hence doesn't exist in the context of the question^. minimum is 1 (if lucky - 25% chance by picking 2 balls at random) & max is 2 (using most efficientl process to absolutely determine without luck - 3/3/2 scenario) While Symantec was busy weighing my balls I took a job with NetApp.... They need to focus on hiring good, capable security engineers, not weighing their balls. The point of these interview questions is to both check your logical brain function and to hear how you think. Most of you are just posting jerk off answers trying to be funny, or you are really dumb. These answer get you nowhere with me in an interview. Think out loud, go down the wrong path back track try another logic path, find the answer. None of this "0 if you use your hands". That is fine if you are interviewing for a job in advertising where creativity is desired, nobody wants you writing code like an 8 year old. You have 12 balls, equally big, equally heavy - except for one, which is a little heavier. How would you identify the heavier ball if you could use a pair of balance scales only twice? The problem is based on Binary Search. Split the balls into groups of 4 each. Choose the heavier group. Continue till you get the heavier ball. This can be done in log(8) (base 2) operations, that is, 3. Since there is only one scale available to weigh. You first divide the balls in half. Weigh each group, take the heaviest group. This is using the scale twice so far. Now, divide the previous heaviest group into half, weigh both groups. Take the heaviest. Divide this last group and take the heaviest. This is the heaviest ball. We have used the scale 5 times. Show more responses Would it be wrong to say for a sample size as small as 8, we might as well not waste time thinking about an optimal solution and just use the scale 7 times, as this will be more efficient than coming up with an ideal solution prior to using the scale? I stumbled across this while looking for something else on Google but I had to answer. It is 2, split balls into 2,3 and 3. weigh the 2 groups of 3 against each other. If equal weigh the group of 2 and the heaviest is obvious. If they are not equal keep heavy group of 3 and weigh 2 of the balls. if equal heaviest ball is one you didn't weigh. If not equal the heavy ball is obvious. 2 times. 8 balls. 1st step: [3] [3] [2] 2nd step: [[1] [1] [1]] [[1] [1] [1]] [[1] [1]] No idea The fewest number of times to use the scale to find the heavier would be Eight to One times ? It will actually be 1 because the question asks what's the fewest amount of times which is one because you could just get lucky you can use any method you want it would still be one because that is the fewest amount of turns you can have It's one. The fewest number of tries on using a balance scale would be one. If you put one ball on each side and one is heavier, you have the found the heavier ball. Use an equilateral triangular lamina which is of uniform mass throughout. It is balanced on a pole or a similar structure. Steps: Place 2 balls at each corner (total 6 balls) i. if the odd ball is one of those, one side will either go up or go down. Now repeat the process with one ball at each corner including the 2 unbalanced ones. ii. if balance is perfect, repeat the process with the remaining two balls and one of the already weighed balls. test answer 2016-01-12 00:34:07 +0000 Show more responses You would not be able to find a ball heavier than the others. All eight balls are identical; therefore, they must all be the same weight. Correct answer has already been posted. I just want to contribute some theoretical analysis. Given N balls, one of them is heavier. Finding out the ball requires log3(N) trit of information. (trit is the 3-base version of bit). Each weighing may give you one of the three outcomes: equal, left-heavier, right-heavier. So the amount of information given by each weighing is upper-bounded at 1 trit. Therefore, theoretical lower-bound for number of weighings in the worst case is log3(N), which is actually attainable. So 27 such balls need only 3 weighings and 243 balls need only 5 weighings, etc. 2 as many have indicated above. The 3 is the kneejerk reaction but 2 is the correct answer. Marty's answer is correct, but he does not explain why. The logic of the balance scale is three-valued: . Its most efficient use is the recursive application of the three-valued logic until there is only one item left. The integral ceiling of ln(x)/ln(3) thus gives the fewest number of times you have to use the balance scale to find the uniquely heaviest ball of x balls. Ceiling(ln(8)/ln(3)) = 2. TvRef Reviewing the answers from over the years has been fun! Some time I would like to be the interviewer to ask these kinds of questions. In first looking at the question, I thought, "probably eliminate as many as possible with the 4 and 4" but then why would it he a thought experiment, less one in an interview, if it was so 2 dimensional? Whether or not getting to the best answer is much of the point, being reductionist by ignoring details, like the context of who is asking, lead me to go my own way as of the question was just text on a screen. There's a lot of 3 dimensional information you could get from someone by this question -- how nervous they are, if they don't then you see how they handle that, or how much they think of their answers to anything. I wonder, were the semantic holes in the question also intentional? In the comments people have written about technicalities -- things about how it wasn't specified that they were only visually identical, and therefore the question is contradictory. Or, how it didn't explicitly specify how to consistently, by most likely repeated efficient scenario, find the heavier ball, so people started that the least possible would be 1 if lucky. Then, since it wasn't explicit that you have to know which one was heavier, people said you could go 0 and guess the right one without the scale, either by direct guessing or trusting your hands with an unspecified sized difference in weight. If the word choice is designed to allow for those, perhaps the question is even more fun than I thought. One could see where and if one goes or gets hung up, see if one would ask clarification if they got hung up, or claim steadfastly about their thoughts being the most important on it, or focus elsewhere -- then that would be another layer to the question that makes it more interesting than I originally thought. I like tea. Show more responses One or more comments have been removed. |
Software Engineer at Cerner was asked...
Allergy,posting date according to timezone,person demographics problem Medication Frequency problem and given error log to identify error Fever temperature problem and discuss a time when you automated a task to make life easier 43 AnswersHi . Did they inform about results till now? Hi ..Yes i got the offer! Can you please elaborate the question ? Show more responses How many days did it take to respond ? My recruiter responded after a week Can I please have the answer? Hi Here are the questions: 1st hour: 1) Design a system for entering and displaying the allergies patients have with given fields! 2) Person Demographic Problem to store information about every person! 3)To record a new born's birth date and time reflecting the timezone. 2nd hour: 1) Implementing a system that notifies nurse when a patient should receive medications 2) An error log is give , we need to identify error 3rd hour: Temperature class to know whether patient has fever or not and in what location is the reading taken such as mouth,armpit,ear For some questions answers are posted in glassdoor! Hi...did you answer all the questions correctly?? They asked me the same questions. I have answered the programs correctly except that fever program there i got bit confusion.but I couldn't properly explain the error log. Hey i didnt answer all the questions correctly ..they helped me if i am struck .. Is this for entry level or new grad position? Can you explain how to notify a nurse please ? They are hiring new grads also for these Software Engineer positions! Show more responses I dont have the logic for medication question..when i was struck in this question..Interviewer helped me that u can implement a queue algorithm! What is the relation between queue algorithm and notify? Well he(interviewer) just said that as a queue is a fifo datastructure..when a nurse looks for medication, it shows the first medication to be given and then it shows the next one when to be given. I dint implement the logic!! my hr status is showing a . (dot) , any idea what does this status tell It means there are chances you are going to get the offer! And for how many days did your status change? Thanks, I had Interview on Last Thursday and status changed to dot(.) on Monday Do we have to wear a suit for onsite rounds? not required Hey, even my status changed from interviewing to dot(.) Did you end up getting the job eventually? I had my Experience Cerner Day on June 30. As of today July 8, my HR Status says "Interviewing." What is my chance of getting the offer? Show more responses @above Hey, even I came to Experience Cerner Day on June 30th, my HR status went from interviewing to dot(.) on July 6th. Any idea what this means? do you know anyone you came that day to get the offer? No, I don't know anyone who came that day. My status also changed to . (dot) I got selected with .(dot) status @above, your status changed to dot and you got offer? Can I know when you had your interview, when it changed to dot and when you got offer? Can someone please provide approximate answers to those FEVER and NOTIFY NURSE MEDICATION problems?? I had my interview on July 8th. The status is still "Interviewing". I emailed the recruiter too but no reply yet. What should i expect with this? Hi ! Even I had my interview on July 7th. I did'nt got any response. Can we still expect ? Hi, this is the response i got when i asked for update on Thursday the next week... Thanks for following up again! As was stated, we do ask that you please give the recruiters about two weeks time to get back to you with a response. Tomorrow will mark the two week time period so you should hear something soon! If you don’t hear anything next week, feel free to reach back out! But my status on portal is still "Interviewing", any chance? How long does it take to get feedback from them?? Hi ,if u dont mind, how much time did your first phone interview last? Show more responses I had interview on 21st Sep,2016 in Malvern,PA for software engineer position did anyone give interview on the same day? They are 3 rounds of interview on the same day back to back lasting 1hr each. Does anyone got the result or feedback from the HR or recruiter? How long does it take for Cerner to give the decision in this case? I emailed HR regarding the decision no reply yet. Is there anyone with the similar situation. Portal status "Interviewing". Hey what are questions asked in the interview, can you please elaborate them because I have an interview for Software Engineer Malvern, PA position. I had my interview on 21sep 2016, PA position. Still waiting for the feedback. Did anyone got the feedback interviewed on 21st sep? Hi, I had my interview last week. It shows .(dot) status in application status. Any idea what does it mean? .How many days does it take to get back? So if the status changes to .(dot) , does it mean I am selected or still not? Did anybody with .(dot) got rejected too? Please post here. @above Did you get selected? And is there anyone who got rejected with the .(dot) status. @above can anyone please confirm .(dot) status means we got the job. Hey, Are they expecting a solution using Threads for the medication problem? How did you add the alert functionality for the nurse? |
Given 5 pirates on a ship, they need to distribute a pot of gold that has 100 gold pieces inside of it. The first pirate must make a proposal of how the gold will be distributed. If he receives over 50% votes from the remaining pirates, then his proposal will be accepted and the gold will be distributed. If he receives less then 50% support, then he will be thrown off the ship and die. 42 AnswersThe answer is for the first pirate to offer the 3rd and 5th pirates 1 gold each, and then take the remaining gold for himself. Otherwise the 3rd and 5th will probably not receive any gold. this is an extremely subjective question. first the nature of the pirates must be examined. if this is truly a team, then of course each pirate should receive 20 pieces of gold. however, if there is a division of labor that affords certain pirates greater responsibility then we are looking at a vertically stratified solution. in this case those at the top, the CEO's of the pirates, must be given more of the booty. if there is no stratification, but the nature of the pirates is individualistic and greedy, i would assume divide the gold into pirates 2 and 4 get 25 + you get 20 + pirates 3 and 5 each get 15. The first answer is right. You need to think that the pirates are rational and greedy for the most they can get. Then you need to consider what would happen with two pirates and take it from there. Show more responses He needs to shoot the ring leader(dominant) of the remaining 4 pirates and re-negotiate after reloading. There isn't an optimal solution for the first pirate. The first pirate can't come up with a solution that will give 2 other pirates a maximum of the gold. The other pirates will always vote no unless the first pirate gives one of them all 100 pieces, since it's always in their best interests to dump the guy overboard and split it amongst less people. It's the wrong question. The question correctly stated is as follows: (credit to vorg.ca) Five buccaneers have obtained 100 doubloons and have to divide up the loot. The buccaneers are all extremely intelligent, treacherous and selfish (especially the captain). The captain always proposes a distribution of the loot. All buccaneers vote on the proposal, and if half the crew or more go "Aye", the loot is divided as proposed, as no buccaneer would be willing to take on the captain without superior force on their side. If the captain fails to obtain support of at least half his crew (which includes himself), he faces a mutiny, and all buccaneers will turn against him and make him walk the plank. The buccaneers start over again with the next senior buccaneer as captain. What is the maximum number of doubloons the captain can keep without risking his life? 20 pieces. The captain should divide the pie equally 5 ways (20 pieces). Then explain to the four pirates that anyone who does not agree to this fair deal of equal distribution will receive nothing, and that person's share will be retained by the captain alone. No one would want the captain to get their share. Everyone would think the deal fair. And therefore the captain's life would not be at risk at all. Be bold, be treacherous, be past tense: I took Pirate 2 and Pirate 3 aside. I told them, "We will split the gold evenly, three ways, between us. We three can overpower Pirate 4 and Pirate 5, so they do not receive any gold." Then I took Pirate 4 and Pirate 5 aside. I told them, "We will split the gold evenly, three ways, between us. We three can overpower Pirate 2 and Pirate 3, so they do not receive any gold." The vote was 100%, and I got away with all the gold, since each of the other pirates killed each other for being doublecrossed. Since I'm telling the story, it's clear I survived. Splitting the gold amongst 3 of the 5 pirates (1st pirate included) gets 50% of the remain pirate vote. In this way, the pirates get the most gold and there is a majority to vote against the first pirates death. Navy Seals kill all the pirates and return the gold to the rightful owner. Show more responses The leader can keep 98 of the gold coins and give 1 to the 2nd ranked and 1 to the 4th ranked pirates. Let's assume 1st that they are so selfish that they care more about the money than each other's lives, and 2nd, that they follow this 50% rule without question. The lowest ranking pirate, number 5, has absolutely no reason to support any other pirates, because he knows that if all the other pirates walk the plank he gets 100 pieces. Pirate number 4 knows that if he's left with pirate 5, pirate 5 will demand all the booty or vote against the proposal to kill 4 and receive it anyway. Pirate 3 recognizes pirate 4's predicament and would only have to offer him 1 piece of gold so that 4 would come out better than being stuck with making the decision and losing everything. His support would provide 3 with a majority. If it came down to pirate 3's decision, he would have 99 pieces, 4 would have 1 and 5 would have 0. If the second ranked pirate, pirate 2, was faced with negotiating, he would need the support of 2 additional constituents. 5 will always vote against him, and 3 recognizes that he can make 99 pieces of booty if he's in control. In order to live, pirate 2 would have to offer pirate 3 99 pieces and pirate 4 1 piece, leaving him with nothing. Pirate number 1 similarly recognizes the predicament of pirate 2. Pirate 1 only needs two other supporters. That's easy. Better that pirate 2 receives his life and even one piece of gold than nothing. Pirate one offers him 1 piece of gold. Similarly, pirate 4 knows that he can get 1 piece of gold and his life, so pirate 1 offers him 1 piece of gold and has his support. After giving pirate 2 and pirate 4 one piece of gold each, he has their support and can take the remaining 98 pieces for himself. QED! Yeah baby! The rationale set forth by Marketing and Information Systems Major is well-explained and thought out, but with one fatal error (i.e. my user name). The interviewee is correct. Suppose that pirates are named by letters, with the most junior pirate in each scenario being Pirate A. I'll list the pirates in order of seniority for each case: In a two-pirate case (Captain, Pirate A), the captain always keeps the booty. Pirate A has no leverage whatsoever, since he'll never have superior force to remove the captain. In a three-pirate case (Captain, Pirate B, Pirate A), the captain only needs one vote. Pirate B wants to get rid of the Captain so he can be in the advantageous two-pirate case. Pirate A wants to AVOID that, so the Captain easily buys Pirate A's vote with one gold coin -- the status quo is maintained, and Pirate B gets shafted. In a four-pirate case (Captain, Pirate C, Pirate B, Pirate A), the captain still only needs one vote (a tie means no superior force, which means the status quo is maintained and the captain wins). We pose our standard question: "If the captain loses the vote, who gets shafted?" -- well, if the captain loses, it's a three-pirate case, which means Pirate B gets shafted. So the captain easily buys Pirate B's vote with one gold coin, and the status quo is maintained. Result: Pirates A and C got shafted. In the desired five-pirate case (captain, Pirate D, Pirate C, Pirate B, Pirate A), the captain needs TWO votes to avoid losing power. So we ask ourselves: "if the captain loses the vote, who gets shafted?" -- Pirates A and C (as determined above, in the four-pirate case). Therefore, to maintain the status quo, the captain proposes one gold coin to Pirates A and C each, and keeps 98% of the booty for himself. The downfall of these pirates is their inability to think laterally or deeply e.g. it's a machine question, not a human question. Subjective variables such as selflessness and morality would make these pirates much less predictable, forcing the captain to appease each and every one of them to the best of his ability, rather than knowing exactly whose vote to buy and at what price. by "deeply" i meant creatively, and by "e.g." i meant "i.e."!! edits would be awesome. The answer is 25. If they split it 5 ways, then its 20 each. If he needs 3 votes, offer each of them 25 and nothing to the last guy, then they will approve, since 25 is more than 20 (even split). Given that the first pirate needs the majority of the remaining vote (3/4) pirates. Then, First Pirate - 25g Crew Member 2 - 25g Crew Member 3 - 25g Crew Member 4 - 25g Crew Member 5 - 0g My logic behind this is simple. In order for their greed not to be outweighed by their survival the 4 pirates can share the booty equally with the 5th pirate as an example of the position they would find themselves in. 5th Pirate gets thrown of the ship and dies. It could stop here or they could revote, If they revote then, First Pirate - 33.3g Second Pirate - 33.3g Third Pirate - 33.3g Fourth Pirate - 0g Rinse and repeat until two pirates left sharing the loot 50g each. Wait, read the clue carefully. Let's say I'm the captain, and my pirates are 'greedy'. Option #1: I give myself and 4 pirates 20 gold each. That's good, right? Wrong. The pirates are 'greedy', and the 4 pirates will STILL vote to throw me overboard, because that would increase their 'take' to 25 Gold each, since I no longer get any. In order for me to WIN, I need to provide them with MORE than 25 Gold each, because that's what they will get for voting me off. Therefore: I keep 22 Gold, and I give pirates 1,2,3 each 26 GOLD. That means, if they vote me off, they will only get 25 Gold, and 26 is more than 25. Thus, the maximum I can keep is 22 Gold. BUT, if it only takes 2 Votes (i.e, my vote counts), then I keep 34 Gold, and give pirate 2 and 3 33 Gold each. Thus, my vote + 2 pirates >50% of the votes. Pirates 3,4 get zero. if they're going to kill you if you can't get 2 guys to back you up, then they can just as easily all four decide to kill you and then the remaining four are in the same quandry, but with only four shares. keep recursing until there is only one guy with all the gold. your only chance is to give them all the gold in the hope that they will deign to let you live, then kill them while they sleep and take it back. This problem really has no solution to it - as it clearly says the one who is proposing distribution doesn't get to vote! figure this: the lead pirate proposes a solution (98 for himself, 1/1/0/0 for others; or any other option) - but he doesn't get to vote. The others can always call this an unfair division and throw the helpless pirate out - as he doesn't have any say. Even if they decide to divide it as 20 coins each, the others can still throw the first pirate and maximise their share by 25% each - this can go on until the youngest/last pirate walks out with all the money. therefore this is an impractical situation. However, the whole situation changes if you allow the pirate proposing the distribution to vote!!! Then the solution, as proposed by some one above, of a distribution being 98/1/1/0/0 will eventually be accepted. Search for the pirate game on Wikipedia, the question is a straight lift of that puzzle - except that someone decided to change the problem by making the lead pirate non-voting.....and that will always make this problem non-solvable. PS: @ mktg and Systems major: Baby, you forgot to read the problem correctly and just googled it up!!! OK, so within the parameters as outlined, and assuming that this problem is recursive (after the first pirate doesn't get enough votes, he's killed, and they're faced with a 4-pirate situation), let's look at it thusly: They're all greedy, and they all know that the best way is to kill everyone else and grab all of the loot. However, to do this, they _must_ be the "lowest pirate" on the pole (the last one to be given the chance of dividing the loot). If this "pecking order" is fixed (everyone knows exactly how they stand), it is different from if it is random. Let's look at both. 5-Pirates, fixed order: In this case, then the proposal outlined by Gus and the others that results in Pirate 5 getting 98 coins, and 4 and 2 getting 1 coin each works out best. 5-Pirates, random order: This is different, as the problem then becomes how the order is established after each pirate gets killed. Everybody wants to be the Last Pirate Standing (tm) (Fox, call me for show marketing rights), but as the first one gets killed, there is increasing odds that they will be chosen next, and not be the LPS. Unfortunately, in the question as posted (5 nameless, rank-less pirates) we don't know how pirate 5 got chosen to choose, and we don't know how pirate 4 will be chosen after pirate 5's demise. In this case, Pirate 5's best play would be to give two pirates 34 gold (one more than 33, and him take 32) if only two votes are needed, or give three pirates 26 gold (one more than 25, and him take 22) if a majority vote is needed, and hope that they would see this as fitting, instead of being the next sap in the position of making a 4-way split or his life. Show more responses As stated the answer is: 25 gold pieces should go to any three pirates, with the leader keeping the remaining 25 for himself. Note - Gus' solution is incorrect because he assumes that the leader can vote on his own proposal. The leader can't. Also - as some others have pointed out, this probably isn't the right question. The question with a "succession plan" has a more interesting answer. Here is the detailed reasoning: So - I start by assuming that for all pirates, its infinitely more important to be alive than to get any gold, but if they are alive, they want as much gold as possible. The pirates, other than the leader are "unorganized", and all things being equal, they would rather have as many pirates around as possible. These are risk adverse pirates :) Assume there was one pirate: the best proposal - take all the gold for himself, which would definitely pass. If there were two pirates, unless the leader proposes to give all of the gold to other pirate, his companion will vote against it, and take all of the gold. If there are three pirates: if the other two pirates have a 50% of getting nothing and a 50% chance of getting 100 gold. So the expected value for both them is 50 gold pieces. He needs two votes to stay alive, so offering either of them less than 50 will assure losing a vote, and thus his life. Therefore, the leader proposes 50 gold to each of the other pirates, and stays alive. If there are four pirates: The remaining pirates have a 33% chance of getting nothing, and a 66% chance of getting 50 gold pieces if they reject the leader's offer. Their expected value is 33 gold pieces each. Offering any two of them 33 gold pieces, and with the leader keeping 34 is a proposal that should pass. If there are five pirates: for the four remaining pirates, they have a 25% chance of getting 34 gold pieces, a 50% chance of getting 33, and a 25% chance of getting nothing if they reject the leader's proposal. Their expected value is: 25 gold pieces. Since three votes are needed, 25 gold pieces should go to any three pirates, with the leader keeping the remaining 25 for himself. Are you joking? Pirates aren't fair! One pirate cheats all the others and splits with all the booty AND your women... They're pirates for chrissake! If I were the 1st pirate, I'd consider that goal #1 is to stay alive - my life is worth more than all the gold. So I'd propose that each of the other four pirates would receive 21 pieces of gold and I'd keep 16... and my life. Odds are that the other pirates would find this acceptable, and they may even keep me around to make the first proposal again next time. It's a win-win. We all keep our lives and get more gold than we had before. I can't speak for other pirates, but that's what I'd do. The proposal has to be accepted by two of the four other pirates. The only way the first pirate can do this is interview each of the other pirates individually and ask what they think is fair. His objective is to find two that are similar enough that he can modify the two into one plan. After mofifying the two plans into one plan he then goes back and asks these two individually again if the modified plan is acceptable. If he can get these two to accept the modified plan then he presents it. It doesn't matter what the other two pirates who were left out think because he has the two votes he needs. There's a pot of gold no one's seeing. The end game is that the last two will share 50 gold pieces each (no majority to mutiny). So pick two friends, offer them the 100 gold pieces between them, and hope they give you some afterward (but don't bet on it). Keep the gold pot and the friends. You lose two votes from those disenfranchised, but you and two friends hold majority might. Here's my thought about this. 100 gold to be distributed to 5 pirates The first pirate proposes how it will be distributed. He has to get 3 out of 4 votes in order to stay alive, otherwise he will be thrown out of ship and die. Let's say pirates are in nature greedy. Second/third/fourth/fifth pirate will rather kill the first pirate to accumulate more share of gold. If the first pirate proposes anything that doesn't let him get even a gold, his proposal might be accepted and he will remain alive. Ofcourse it might not be what will happen. The other pirates kill the first pirate and they quarrel over the pot of gold. The last-man-standing gets everything. Or they all die and no-one gets anything. The answer is 97. Start with three pirates. I was once faced with this very same dillemma...I ended up splitting the gold between three of the other pirates, which got me the vote I needed. Yargh, but then me and me accomplice, the man without any gold, we shivved all the rest and threw the bodies overboard, each claiming 50 gold, yar! Attach the gold to a life preserver and throw it overboard . If they are so greedy they will all dive after it. You sail away with the ship and sell it for much more than 100 pieces of gold. First, you must realize this is not just a logic question with one right answer, but a way for an employer to probe you thinking process as you talk out loud. So if you make stupid assumptions like “I’m the captain so they will let me have more” or “I will just kill them later” or “I would strike a side deal”, then you will be looked at as a dodger or lazy or scared to address the question, so that crap is out in an interview. You might get points with this one good assumption: “It looks like the question is incomplete, I assume that the voting rounds continue until an offer is accepted or only one pirate is left.” Facts: in round 1 the offeror needs 3 of 4 votes for a majority. In round 2 he needs 2 of 3, in round 3 he needs 2 of 2 and in round 4 he needs 1 of 1. (So now you are showing the interviewer you are thinking ahead before rushing off trying to give the answer). So the offeror in the first round wants to maximize his gold and his chance of living. So he makes this offer. 33 Gold to each of 3 voters and 1 for himself. He explains why this is the best they can hope for as such. In the final round, the 1 voter either gets 100 pieces of declines the offer, kills the pirate and takes 100 anyway. He can even legally decline the offer of 100, kill the pirate and still take 100 pieces. Now you may think this is good, but the odds of one of the 4 of you being alive and being the voter is 1 in 4 or 25% (see mister interviewer, I can to simple math). So you have a 25% chance of 100 pieces, or 25 on average, so 33 and guaranteed life now is a better deal, in fact you should be happy if I offered you 26. But I want to take just one, so in the next round, the offeror will have to take 1 or less or face certain death, because he saw me die for just 1. In the next round, that means the 2 winning voters will want 50 pieces each. But they only have a 50% chance of being 2 of the 4 people being offered gold. That means they have a 50% chance of getting 50 pieces, on average, they get 25, again less than 33. If they want to try to make it to round 3, there will be 1 offeror and he will have to get both votes for a majority to live, so again he will have to be willing to give 50 to each. From round 1, the 4 have a 50% chance of being a voter now and a 50% chance of being dead or getting 0 and living. If they get 50 pieces, then 50% of that is 25. Still less than 33. Also, the offeror can argue that if they don’t accept his offer, then one of them will die and/or get 0 in next round, the other will get 100, but at this point on average would get only 50. So he might be willing to offer each much less then 50 to guarantee they live, so now they are worse off. In no average case are they better off than taking your 26-33 piece offer and the certainty of life. (Now, if I am the first offeror, I will probably max out their offer at 33 so I maximize my chance to live and fight another day). Or you just pull out your light saber and kill the other 4. Show more responses You need to look at the question from the end first. As each pirate is thrown off the ship, there are fewer pirates to split the gold up with. At the end there will be 1 pirate who gets all 100 pieces of gold. Pirate 5 1 pirate 100 With two pirates, the situation looks like this: Pirate 4 Pirate 5 2 pirates 0 100 1 pirate 100 Pirate 5 has no reason to accept any offer other than all the gold, since if he rejects Pirate 4’s offer, he will get all the gold, anyway. With three pirates: Pirate 3 Pirate 4 Pirate 5 3 pirates 99 1 0 2 pirates 0 100 1 pirate 100 With 1 or 2 pirates, Pirate 5 has all the power, but with three pirates, 1 piece of gold for Pirate 4 is better than any of the other conditions. With four pirates: Pirate 2 Pirate 3 Pirate 4 Pirate 5 4 pirates 97 0 2 1 3 pirates 99 1 0 2 pirates 0 100 1 pirate 100 With four pirates, Pirate 4 and 5 get a better deal than with 3 pirates. With five pirates: Pirate 1 Pirate 2 Pirate Pirate 4 Pirate 5 5 pirates 97 0 1 0 2 4 pirates 97 0 2 1 3 pirates 99 1 0 2 pirates 0 100 1 pirate 100 Pirate 3 and 5 get a better deal than with 4 pirates. I have just a few things to add that seem logical in order to know how to determine the answer. The most important thing to know is whether they are distributing the gold while at sea or near land (or in port). If they are at sea there is a far greater likelihood that the captain would survive regardless of the distribution, since it takes several people to man a ship. If they are near land, the answer can only be determined by knowing the personalities of the crew and how much fear or respect the captain commands. The more fearsome the captain is, the less likelihood of a mutiny regardless of the division as long as each of the subordinates received an equitable portion and the captains share was not overly large. The idea of 'friends' among pirates is ludicrous- pirates by nature form alliances merely for numbers, and are by defination treacherous. The idea of trying to solve the problem mathmatically is interesting but unsubstantiated as the outcome of gold division vs staying alive would invariably be determined by the variable factors I outlined above. By solving the problem through manipulating the pirates desire to be the only one left alive, there is an underlying assumption that only one pirate is necessary to sail a large vessal at sea, which is not the case, and even pirates know that. you find the solution by starting from the opposite end. Start with the scenario where only pirate D and E remains alive. Then D will keep everything to himself. Knowing this (if C was alive) he would offer just one gold coin to E (since he knows what happens if they choose to kill C - then E gets nothing). Continue to the point where A is still alive and you'll find: A=98, C:1, E:1 The question should also be that: if the top ranked pirate dies, then the whole process is repeated for the 4 remaining pirates, and so on: if the 2nd ranked pirate dies, it is repeated for the 3 remaining pirates... and so forth... And the answer should be that if all pirates are strictly purely logically and think for himself only, then the top pirate will get 98 coins. This question seems to suggest 2 things: 1) Since the top ranked pirate can get the most gold coins, it justifies why the top person in a company get most of the money and the fraction of the fraction is left for the people underneath. 2) Since it assumes that people underneath will not team up, maybe that's why in some companies, it is the benefit of the top for the people underneath not to be in good relationship, so that it mimics the situation above, so that the top person can get most of the gold coins. also note that if makes a difference whether if 50% of the vote is established, whether the top pirate die or whether the proposal is accepted. > 2) Since it assumes that people underneath will not team up, maybe that's why in some companies, it is the benefit of the top for the people underneath not to be in good relationship, so that it mimics the situation above, so that the top person can get most of the gold coins. so those companies will actually want to foster a bad relationship between people underneath. And will that company want to hire "good guys" for the company? No, because the good people are good with each other and can team up. If there are many many bad guys, then they will be all greedy and hate each other and think for themselves only and not team up. Therefore, the company may want to hire bad guys instead of good guys. this is a trick question. if the point is to guarantee that he stay alive, he needs to make 3 pirates as happy as possible. the only way to do that is to split the entire share evenly between them. this means excluding one pirate AND HIMSELF. "Anyone who's with me and votes for my proposal gets an equal share of gold. Vote against me, and you get nothing while the rest of us gets an even more equal share of the booty." Assume you are the pirate who distribute the gold, you just put the gold to a heap one by one and let the rest pirate to decide when to stop picking, the first person who says 'stop' will get the whole golds in this heap and the others must distribute the other golds. One or more comments have been removed. |
Software Engineer at Facebook was asked...
You have two lightbulbs and a 100-storey building. You want to find the floor at which the bulbs will break when dropped. Find the floor using the least number of drops. 38 AnswersStart moving up in increments of 10 floors and dropping the bulb until it breaks (ie: drop from floor 10, if it doesn't break, drop from floor 20, etc.). Once the bulb breaks, move down to the floor above the last floor it broke on and start moving up floors in increments of one until the second bulb breaks. This results in a worst case scenario of 19 drops. Surely a binary search method would be more efficient i.e. starting at 50 and either going up or down 25 floors based on if it breaks or not. If you do a binary search, what happens if it breaks at floors 50 and 25? Show more responses Do you know what a binary search is? You drop it from floor 12 next. If it breaks, you know it breaks between floors 12 and 1, inclusive. If it doesn't, you know it breaks between floors 13 and 25, inclusive. The main principle of binary search is that with each step you reduce your search space in half. Now your search space consists of only 12 floors. Wow, I want to get asked such a question in an interview! >>you drop it from floor 12 next... if you broke it on 50 and 25... you are out of luck and out of bulbs... 19 drops is not the best worst case scenario... imagine trying floor 16, if it breaks, you try 1 - 15 and thats 16 tries. if it doesn't break, then try floor 31 and if it breaks, then try 17 - 30 (so 16 tries, including the try on floor 16). And on and on (45, 58, 70, 81, 91, 100). If you reach 91, you'll have tried 7 floors so far and if it doesn't break, then there's 9 more tries to get to 100 (thus 16 in the worst case) Even a drop from the ceiling of 1st floor, a simple light bulb will break. thats what i think It's a light bulb. It will break when dropped from the 2nd floor. Drop it there then go to the first floor, hold it over your head and drop it. first do a binary search (agressive first step - fast) with 1 bulb. when first breaks, you know X(last but one fall - success) and Y(last fall - failure). now do a linear search starting from X(conservative but accurate second step - slow). complexity = in between logN and N. Use Binary search starting with the middle 50 The complexity of binary search is logN . So it will be log(100) < 7. Based on my experience, I think it will be floor 1 itself . Drop from 1st floor. If it didn't break, drop the same bulb from 2nd. If it still didn't break, drop the same bulb from 3rd... repeat as necessary. Only one light bulb required :) Yes, but doing each floor, that will give you the most drops -- question relates to optimizing for "least" number of drops -- I didn't think about being able to re-use the bulbs...that obviously is helpful. Maybe a fibonaci sequence once you determine a "break" floor and a "non-break" floor. I'd probably fail completely at coding it...knowledge of optimization and prediction theory would certainly be useful. Let f(m,k) be number of tries for m lamps and k floors. Obviously f(1,k)=k. let f(2,k) be s. k<=(s-1)+(s-2)...(1) =s(s-1)/2. Therefore f(2,100)=15. Show more responses Actually, 16 is not the optimal, nor is 15; you can do it in 14. Here is one solution (there are at least 5 other equivalents): * Drop first bulb at 14th, 27th, 39th, 50th, 60th, 69th, 78th, 85th, 91st, 96th, and (optionally) 100th until it breaks. * Go to the highest floor where the first bulb didn't break. * Repeatedly go up one floor and drop the second bulb. When it breaks, you have your answer. Why is 14 optimal? Since you are decrementing each time, you want (n) such that sum(1..n) barely reaches 100. The answer is n=14. Generally, if the number of floors is (f), the lowest number of drops is ceil((sqrt(8*f+1)-1)/2). This is the best worst-case scenario. An interesting related question is what gives the lowest expected number of drops. And no, I could not have gotten this in an interview. In theory, use one bulb to determine an interval, and use the second bulb for a linear search within the interval. The solution that decreases the interval by one for each trial is quite clever. In practice, however, take the nature of the problem into account: Start on the first floor and move up by one floor. That's the answer I would be looking for. Start with bulb 1 and drop it from floor 2. Doesnt break? then floor 4 Doesnt break? keep dropping the same bulb moving even number of floors all the way upto floor 100. If on some even floor the bulb breaks drop the second bulb from the odd floor below the even floor, to detect if its the even or the odd floor that breaks the bulb Best case detection: 2 tries (first bulb breaks on 2nd floor, second bulb breaks on 1st floor) Worst case: 51 tries (the fist bulb breaks at 100 and second bulb breaks or does not break at 99th floor.. ) Go to the 100th floor and drop the first bulb. It WILL break. Done, 1 drop. It doesnt say whats the lowest floor it will break at, just at what floor will it break with least drops. Thus floor 100. Alright guys...you have two light bulbs. ...the second one has to be used for linear search, let the worst case number of items to be searched be x, then your interval will also have to be x, which will result a worst case of 100/x drops for the first light bulb. So now you are just trying to minimize n=100/x+x, find n'=0 when x=19...the candidate's answer is correct. I meant...x=10. and n=19. 0 drops, 1 bulb......stop thinking like computer nerds. Use physics or an engineering mindset. They didn't prohibit the use of any tools. Grab a scale, figure out force req'd to fracture bulb. Calculate acceleration due to gravity adjusting for air resistance/barometric pressure at location (trivial for anyone who took a 1yr physics course). Figure out how many meters up you need to be based on the req'd acceleration. Done.... @Rich: I am sure they were hoping for you to give them a computing answer since they don't do physics, and rather do computer science. mer's answer is correct: 14. Let F(s, n) be the optimal worst-case number drops for s stories and n bulbs. Suppose we drop at floor f, constituting one drop. If it breaks, we must make up to F(f-1, n-1) drops. If it doesn't break, we must make up to F(s-f, n) drops. Thus, for a given floor f, we have up to 1 + max { F(f-1, n-1), F(s-f, n) } drops. Optimizing over f: F(s, n) = 1 + min{ max { F(f-1, n-1), F(s-f, n) } for f in 1..s} Using the appropriate base cases, we have F(100, 2) = 14, as mer has given. Another way to think about it is in terms of decision trees. We want to construct a binary decision tree with leaf nodes for floors 1..100, and at most one "left" turn per path from root to leaf. To minimize the height of the tree, we want to reduce the variance in the length of each root-to-leaf path. This suggest we try dropping the first bulb at floors of the form: a, a-1, a-2, .. a-b, where the sum a + (a-1) + .. + (a-b) is equal to or barely over 100, so that determining almost any floor (possibly excluding the top few) takes a drops. Using this approach, we get the sequence of drops that mer has suggested. Well done @mer I have seen this question posed many ways, and that is the best answer I have ever seen. Sure hope I get asked this one now Show more responses 14 In my experience light bulbs break when dropped from any height above 3 feet Depends on how accurate u want to be. If i want exact answer, drop one from fifty, if it breaks start from first floor woth the remaining bulb. If it does not break, then start from fifty first florr. u will iterate fifty times as worst case. If u want a approximate answer, u can do binary way with give or take twenty five floors. Step over based on accuracy needed. You are all ignoring valuable information in this question. We are talking lightbulb, not bowling ball, and building, not step ladder. The bulb will almost certainly break by being dropped from the second floor (assuming US numbering conventions). The chance of it surviving a 3rd floor drop are miniscule, but not zero. The chance of a 4th floor drop, even less. Therefore, drop it from the 3rd floor first. If it breaks, go to the second floor and try. If that breaks you know the answer is 2. If it by some miracle doesn't break from the 3rd floor drop, the answer is 4, but take the elevator up one floor and drop it just to see. Rinse and repeat to 5, but since it will have already broken, go out and grab a beer, and tell your friends how much fun you just had. n*(n+1)/2 = 100. n approx = 14. In worst case u can figure it out in 14 drops. 14th, 27th, 39th, 50th, 60th, 69th, 78th, 85th, 91st, 96th, and (optionally) 100th until it breaks. I believe the number sequence should be: 14, 27, 39, 50, 60, 69, ** 77, 84, 90, 95, 99 **. The 9 floor gap between floor 69 and 78 would result in 8+8 = 16 drops worst case. Easy. Answer is zero. You don't need a test to find out that a lightbulb is going to break, even when you drop it from the first floor, because it's made of glass. BigO(100/X + X-1), Where X is the number of floors. 100/X calculates the dropping times to break the first one and X-1 is the additional maximum overhead to break the second one starting from the previous dropping floor to the floor the previous bulb was broken. If you solve the derivative of the above equation equal to zero, the optimal solution becomes 9.9 ~= 10 . Worst case = 100/10 + 10 -1 = 19 If its a glass bulb it will break from a 2ft height...i wont even care climbing any floors to check. Show more responses Once you break the first light bulb, you are FORCED to start at the highest safe floor + 1 (i.e. highest floor that you safely dropped bulb #1 from) and drop bulb #2 one floor at a time, moving upward. Therefore, the algorithm for the first light bulb is critical (cuz once it breaks you are counting by 1's upward). Binary search starts at the 50th floor ==> max # drops = 50 Choosing fixed increments rather than binary search, e.g. start at 10, increment by 10, yields better results ==> 25 The ideal solution is 14 drops ==> Start at 14, increment by 14 each step until it breaks (leaving for the reader why 14 is optimal). It doesn't matter what floor you are on to make a bulb break. Doesn't it matter how high off the floor the bulb is dropped. If I am on the 5th floor and the bulb is sitting on the floor of the 5th floor, how high off of that 5th floor do I need to drop it before it breaks. This is a misleading question. The question doesn't say that you will drop the bulb out the window. Drop both from eye level. Both will break, and I answered the question without even climbing one stair. Efficiency isn't always about math..Common sense Answer: 14 drops Mathematically: 14 is the first number n, where the sum of numbers from 1 to n is greater than 100 Trial and error: The worst case happens when the bulbs break at floor 13. If you start from the 14th floor and the bulb breaks, then you start at the bottom floor and work your way up. If it doesn’t break and you try it again from the 28th floor and it breaks, then you go back down to the 15th and work your way up 1 floor at a time. Assuming you know nothing about the light bulb, I believe the 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99 increment would by far be the best option. I compared it against fixed I did the calculations below with this method, fixed increments of 10 and fixed increments of 9. Average Drops per Digit (1-100) - 14inc is 9.47 -10fixed is 10 - 9fixed is 10.02 Max Potential Drops - 14inc is 14 - 10fixed is 19 - 9fixed is 19 Comparing the 3 vs the digits, how many times are they the most efficient method - 14inc wins out 48 times - 10fixed wins 41 times - 9fixed wins 40 times *Note the total is over 100, if there was a tie those methods each got a win. The only concern against the 14 increments is that it performs poorer at the beginning, but if you don't know when exactly it will break and believe that it could be at any floor then it wouldn't matter. One or more comments have been removed. |
Software Engineer at Cerner was asked...
Mostly behavioral, and includes the coding sessions as well. They look at your approach and ask you the questions on what your approach is and why 37 AnswersYou're expected to create the classes upon the questions that they ask. Be ready to explain your approach. Can you please elaborate the questions you faced. Did they send you a mail or any update? How did you come to know about your status? Show more responses It's been two weeks that i've taken the interview. I have not heard it back from them and also there's no "waiting" option mentioned here. Did you take the interview as well? Yes, The status still shows "interviewing". Did you try sending a mail to your HR? Yes. There was no response. What was your interview date? June 28, Heard that they are having 3 weeks of interviews and there is one tomorrow. I'm not sure though, I had my last round a bit late and didn't get the chance to speak with other people. Keep us posted if you get any update. Did you guys get the same prescription/allergy/temperature question? Did any of you guys got conformation or rejection for people who took interview before 29th I appeared on 28th June and still waiting on decision. Anyone got any result who appeared on same date. I had Onsite interview at Cerner campus on June 21 and my status is still 'Interviewing'. Does anyone interviewed on June 21? @ above did you try calling your HR @all Any idea on rejections come out first or offers come out first Show more responses I emailed the HR. She said there are lot of applications and it's taking time. anyone had an interview on June 21? i did Did you got response from them? did anyone hear back yet? No . It's been three weeks now. @all I had my interview on june 21 and got offer on july 11 @above congrats bro do you know any one who got rejected and had interview just before or later of 21st @ continue above what salary did they offer and any signup bonus and relocation things. @interviewee's of 28th June, any update? Show more responses no signing bonus .i am from KC so no relocation for me.No salary negotiation check your application status on candidate portal, if it has "." then probably you got selected @above did your status change to dot(.) if so how many days before you get call did it turn to dot(.) and how many days after interview Whats the Salary they offered ? Could you kindly specify an amount if you don't mind? Thanks in Advance 72k . I personally think it is less and the benfits are not that great. They are not willing to negoniate Thank you man, for posting t he salary. Was it according to what you asked ? Any idea whether this is the base salary, or will they give according to the salary quoted by us . Also congrats man. Hopefully I too will join you soon in Cerner . All the very best to other too :) Had interview on 28th June, got offer on 12th July. @all who got offers when are your joining date? For june 28th candidates do you have any idea how many members came along with you for the interview Hii guys, I was invited for a 3 hour vedio interview on coming week. Can anyone who had taken hirevue before can tell me some tips. Thanks in advance.. Show more responses Hi guys, did anyone had interview on 6th july and heard back? Does anyone had interview on June 21st and still waiting for the decision? do they update the interview date in the portal once they interview you?? or does it remain the same with the first date that they update? Hello people.. if possible please post here when you get an offer along with the date when you interviewed..it might help others who are expecting to hear back from the company.. did people who interviewed on 6th/7th July receive any offers yet? One or more comments have been removed. |
Software Engineer at Apple was asked...
You have a 100 coins laying flat on a table, each with a head side and a tail side. 10 of them are heads up, 90 are tails up. You can't feel, see or in any other way find out which side is up. Split the coins into two piles such that there are the same number of heads in each pile. 36 AnswersAnswer #1: Place 50 coins into two piles on its edges so that both have the same amount of heads in each pile, neither facing up or down. Answer #2: Trick question, place 50 coins in both piles and in theory they all have heads just not necessarily facing up or down. agree with 2nd ans Split into two piles, one with 90 coins and the other with 10. Flip over every coin in the pile with 10 coins. Show more responses Just split into two piles, each with 50 coins. The question only asks 50 heads in each one, it doesn't ask for the number of heads up!!! Pick 10 coins from the pile, flip it and put it in the other pile. This will ensure that the number of heads up are equal in both the piles Pick 10 coins from the original 100 and put them in a separate pile. Then flip those 10 coins over. The two piles are now guaranteed to have the same number of heads. For a general solution of N heads and a total of M coins: 1.) Pick any N coins out of the original group and form a second pile. 2.) Flip the new pile of N coins over. Done. Example (N=2, M=6): Original group is HHTTTT (mixed randomly). Pick any two of these and flip them over. There are only three possible scenarios: 1: The two coins you picked are both tails. New groups are {HHTT} {TT} and when you flip the 2nd group you have {HHTT} and {HH}. 2.) The two coins you picked consist of one head and one tail. New groups are {HTTT} and {HT} and when you flip the 2nd group you have {HTTT} and {TH}. 3.) The two coins you picked are both heads. New groups are {TTTT} and {HH} and when you flip the 2nd group you have {TTTT} and {TT}. The question says "'You' can't feel, see or in any other way find out which side is up....' Can a team member? Cooperate with a fellow engineer, or other colleague, who can see the coins to solve the problem? Question has its answer in it... 10 coins are head up..... 90 coins are tail down..... so it means all 90 coins are head up.... Now, all you have to do is to split it into half. 50/50 Let's generalise the question to where there are n heads and any number of tails on the table. Select any n coins. This set will contain m heads, where m is between 0 and n inclusive, and n - m tails. The other n - m heads will be in the remaining coins. We now have two piles: the selection of n coins with n-m tails and the remainder with n-m heads. All we have to do is flip the selection so that the n-m tails become n-m heads, the same number as the heads in the remainder. This is a straightforward extension of the 'pick any 10 coins and flip' answer correctly given above by several people. All of you are over thinking it. Read the last bloody line, "Split the coins into two piles such that there are the same number of heads in each pile" They're not asking for the heads to be up or down, just an equal amount & every coin has a head side so dividing the pile equally achieves that. 100 coins total, 10 of them are heads up, 90 are tails up. Meaning all of them are heads up AND tails down. Split it 50/50 and you are done. It is not as easy as to just split it. And it says heads UP tails UP. Given 10 h, 90 t. Pick some random 10 coins call it P1. Rest is P2. In P1, (10-x) heads, (x) tails In P2, (x) heads, (90-x) tails Flip the coins in P1. In P1, (x) heads and (10-x) tails P1 and P2 have the same number of heads. reading these answers is such a confidence builder. Show more responses I agree to trev, don't think anyone read the question. we already have 2 piles --> 90 coins with tails up and 10 coins with heads up, just flip over 10 of the coins from 90 coins that have tails up, we will have same number of coins with heads up in each pile. get all coins in your hands, shake them, drop them. for each coin there is a 50% probability to lay heads up, and 50% probability for tails down. now split i half question doesn't need to look faces of which side is up after splitting it in two piles. split all coins in two part of 50 50 and they all have heads ...and thats what questioner asking..! and move them to the 10-coin pile. Take 40coins from 90-coin pile, flip them over and move to the 10-coin pile. It's really depends on whether Apple is hiring Software Engineers who are collaborators, mathematicians or tricksters. It's clear that Apple does hire Engineers who listen to the question accurately. Make two groups at random for 10 and 90 coins. Example:- G1(10) G2(90) case 1:- 6H,4T 4H,86T case2:- 3H,7T 7H,83T Now flip all coins of smaller group G1(10). The result will always have same Heads in each pile. G1(10) G2(90) case 1:- 6T,4H 4H,86T case2:- 3T,7H 7H,83T We just get 5 coins head up put in each piles ==> we get the same number of head up in each pile. They just ask we "Split the coins into two piles such that there are the same number of heads in each pile" . They didn't say that we don't kow what is coin head up and they mixed together. "The question says "'You' can't feel, see or in any other way find out which side is up....' Can a team member? Cooperate with a fellow engineer, or other colleague, who can see the coins to solve the problem?" This is the best answer yet! Completely out of the box answer and yet so simple. Show more responses Flip every other coin, 90 Tails will get split into 45 Heads and 45 Tails. Similarly 10 Heads will get converted to 5 Head and 5 Tails, so now we have 50 heads (45 + 5) and 50 tails (45 + 5). Then just split them into two equal groups. Answer Make a pile of 10 and flip them over. Then the number of heads is equal in both piles. question says both group should have equal heads, but doesnt specifiy, it should be up, hence, just grouping 50 each would solve the problem This is a screw you question, but yeah if you take out 10 coins you can have anywhere between 0-10 heads for every head you have you have one less head in the other pile and one less tail in your pile of 10 coins. So if you have 100 coins 10 heads and you take lets say 10 coins 0 heads, 10 tails. The 90 coins has 10 heads. 1 heads, 9 tails. The 90 coins has 9 heads (you stole one when selecting 10 coins). 2 heads, 8 tails. The 90 coins has 8 heads (same you stole 2 when selecting 10 coins ect). 3 heads, 7 tails. The 90 coins has 7 heads. 4 heads, 6 tails. the 90 coins has 6 heads. 5 heads, 5 tails, the 90 coins has 5 heads. 6 heads, 4 tails, the 90 coins has 4 heads. 7 heads, 3 tails, the 90 coins has 3 heads. 8 heads, 2 tails, the 90 coins has 2 heads. 9 heads, 1 tails, the 90 coins has 1 heads. 10 heads, 0 tails, the 90 coins has 0 heads. As you can see whenever you take out 10 because your not only stealing from the pile of 90's heads your also offsetting the pile of 10 coins tails by 1 equally you have an equal connection between the tails you have in the pile of 10 coins as you do heads in the pile of 90 coins that your tails in 10 coins pile always equals heads in 90 coin pile. So you just flip over each coin in the pile of 10 coins and your tails becomes heads. So if you selected 1 head and in the 10 coins pile you had 9 heads in the 90 coins pile and 9 tails in the 10 coins pile, you are guaranteed after flipping each over once to have 9 heads in the 10 coins pile as tails becomes heads and 9 heads in the 90 coin pile, and ect, ect. This stands true for any pile that you know the amount of one category and 2 options, If you know you have 25 of one things, despite how many things there are if each thing had only two options like heads or tails, you know selecting 25 of them the same amount you know of one thing that when taking out 25 or the equal number of what you know of one thing is in there that what you unsucessfully try to filter out is the inverse of what you selected successfully to take out. Pick 10 coins, flip them and form a separate pile. The no.of tails in both pile will be equal inspite of your choice being a tails up coins or a heads up coins. Coz when u pick a tails up coin u r reducing the no.of tails up in the first pile and since u flip it its gonna b a heads up coin the second pile, if u r picking up a heads up a coin u turn it into a tails up coin in the second pile so that it can cancel out one tails up coin in the existing first pile. If it means heads up then separate the coins into one pile of 90 one pile of 10 then flip the ten coins it works with all scenarios Of sides you ended up choosing also like to point out that we can't feel them so we probably can't use our hands to flip them but I assume they would allow us to use something as how else would we separate them The answer lies in the exact wording of the question "Split the coins into two piles such that there are the same number of heads in each pile. " It does not specify heads need to be face up, so you would simply split the piles in 50 each and you have the same number of coins with heads in each pile. Take ten coins (consider as one pile, Pile A and other 90 coins as another pile, Pile B). Now you have two piles. Turn all coins as in pile A, you will end up with same number of heads in both piles. Ex: Scenario 1: Consider in Pile A, there are 2 heads and 8 tails. Hence in Pile B there will 8 heads.Now when you turn all the coins in Pile A you will end with 8 heads in Pile A. Hence both Pile A and Pile B have same number of heads. Scenario 2: Consider in Pile A, there are 10 heads. Hence in Pile B there will be 0 heads.Now when you turn all the coins in Pile A, you will end with 0 heads in Pile A. Hence both Pile A and Pile B have same number of heads. Scenario 3: Consider in Pile A, there are 0 heads. Hence in Pile B there will be 10 heads.Now when you turn all the coins in Pile A, you will end with 10 heads in Pile A. Hence both Pile A and Pile B have same number of heads. Show more responses Take 10 coins.Split into two piles of 5 each.Flip all coins in one pile.Both piles now have equal heads and tails.Take another 10 and go through the same procedure.Follow the same process for the entire original pile.You end up with two sets of 5 piles having equal no. of heads and tails.Combine all 5 piles on each side and it's done. Its very simple. step 1 take group of 10 coins from all now flip this pile and you will get your answer. how? lets see cases 100 total ( 10 H + 90T) so you get group of 10 from them so lets assume you will get 4 h+6T , and (6H + 84T) then flip this smaller one new group will be 4T+ 6H so now we 2 groups 1 new 1 old 4t+6h and 6h+85T both have same number of heads .... LITERAL ANGLE Split 50/50. Both piles have the same number of heads. Parameters do not require each pile to have the same number of heads facing upward. TEAMWORK ANGLE Ask the most efficient, skilled coin identification analyst at Apple to identify the coins so the skilled sorting robot can separate the piles equally. PATRONIZING ANGLE Take a picture of the table with your iPhone and sending to a laborer hired to come sort for you via a services app in the app store. NEXT LEVEL QUANTUM ANGLE If the coins are in no way observable, the question is impossible to answer because the coins are sitting next to Schrodinger's cat and thus are in a state of both heads and tails until observed. One or more comments have been removed. |
Senior Software Engineer at Google was asked...
Given an array of numbers, replace each number with the product of all the numbers in the array except the number itself *without* using division. 34 AnswersCreate a tree, where the leaf nodes are the initial values in the array. Given array A[1..n] create array B[1..n]= {1} // all elements =1 ; for (i=1; ij) B[i] *=A[j]; } } A=B; To husb: Your answer will work, but it's O(n^2) solution. Can you do better? Show more responses Am I missing something? It can't be this easy: given array[0..n] int total = 0; for(int i=0; i<=n; i++) { total += array[i]; } for(int i=0; i<=n; i++) { array[i] = total-array[i]; } Ah yes.. I was. The question is PRODUCT, not sum. That will teach me to read the question too fast ;) Create a tree, where the leaf nodes are the initial values in the array. Build the binary tree upwards with parent nodes the value of the PRODUCT of its child nodes. After the tree is built, each leaf node's value is replaced by the product of all the value of the "OTHER" child node on its path to root. The pseudo code is like this given int array[1...n] int level_size = n/2; while(level_size != 1){//build the tree int new_array[1...level_size]; for ( int i=0; i left = array[i*2]; (and also from child to parent) new_array[i] -> right = array[i*2+1] new_array[i] = new_array[i] -> right* new_array[i] -> left; (take the product) } array= new_array; level_size /=2; } for(int i=0; iparent; if( parent->left == node){//find the other node under the parent brother = parent->right; } else{ brother = parent->left; } p *= brother; node = parent; } return p; } btw, it's O(n*logn) It seems to me that for any number array[i], you're looking for PRODUCT(all array[j] where j i]) we can simply precompute these "running products" first from left-to-right, then right-to-left, storing the results in arrays. So, leftProduct[0] = array[0]; for j=1; j = 0; j-- rightProduct[j] = rightProduct[j+1]*array[j]; then to get our answer we just overwrite the original array with the desired product array[0] = rightProduct[1]; array[n-1] = leftProduct[n-2]; for j=1; j < n-1; j++ array[j] = leftProduct[j-1] * rightProduct[j+1] and clearly this solution is O(n) since we just traversed the data 3 times and did a constant amount of work for each cell. betterStill, I think you have the answer the interviewer wanted.. But... if the array is google sized, don't we have to worry about overflows? it looks to me can be done in order n time given the following relation: product[n] = product[n-1]*array[n-1]/array[n] for example we have array 2 3 4 5 6 product[0]=3*4*5*6 product[1]=2*4*5*6 array[0] = 2; array[1]=3 product[1]=product[0]*array[0]/array[1] Here are my 2 cents to do this in memory without creating temporary arrays. The simple solution , if division was allowed, was multiple all the elements of the array i.e. tolal = A[0]*A[1]]*....*A[n-1] now take a loop of array and update element i with A[i] = toal/A[i] Since division is not allowed we have to simulate it. If we say X*Y = Z, it means if X is added Y times it is equal to Z e.g. 2*3 = 6, which also means 2+2+2 = 6. This can be used in reverse to find how mach times X is added to get Z. Here is my C solution, which take pointer to array head A[0] and size of array as input void ArrayMult(int *A, int size) { int total= 1; for(int i=0; i< size; ++i) total *= A[i]; for(int i=0; i< size; ++i) { int temp = total; int cnt = 0; while(temp) { temp -=A[i]; cnt++; } A[i] = cnt; } } Speed in O(n) and space is O(1) narya trick is good but really useful as it might take more iterations depending on values... eg. 2,3,1000000000000000 so if you have 3 numbers and if you are trying for the first one it will go for 500000000000000 iterations, hence as the overall product value wrt to the value matters a lot... try something else.... narya, your solution is not O(n). You have to also account for how many times you will run through the inner loop - which will be a lot. You can do it in O(n) time and O(n) space. In one pass, populate B[i] with the product of every number before i. In the second pass, multiply this with the product of every number after i. Can't think of a way to do it without the second array. void ArrayMult(int *A, int size) { runningProduct = 1; int *B = new int[size]; for(int i = 0; i = 0; --i) { B[i] *= runningProduct; runningProduct *= A[i]; } for(int i = 0; i < size; ++i) { A[i] = B[i]; } } Show more responses <strong>Brutefoce Method : </strong> The brute-force method suggests that if we take each element, multiply all elements and store the product in the array B[i], then it would take O(n^2) time. <strong>Other Solution : </strong> The other solution to this problem can be we multiply all the elements of the array "A" and store the product in a variable (say product.), and then divide the product by each element, then we will get the desired array. The C code of the solution can be : #include int main() { int n,i=0; scanf("%d",&n); int arr[n]; int brr[n]; int product = 1; for(i=0;i This solution will take O(n) time. The space complexity of this solution will be O(1). If we have particularly given that "We can't use the *DIVISION* operator, then the solution to this problem will be as follows." polygenelubricants method : Let we have 2 arrays, "A" and "B". Let the length of "A" is 4. i.e. {A[0],A[1],A[2],A[3]} Then we will make two arrays (say temp1 and temp2). One array will be storing the product the array before a particular element and temp2 will store the product of elements after a particular element. temp1 = { 1 , A[0] , A[0]*A[1] , A[0]*A[1]*A[2]} temp2 = {A[1]*A[2]*A[3] , A[2]*A[3] , A[3] , 1} And then we will correspondingly multiply temp1 and temp2 and store in B. B = {A[1]*A[2]*A[3] , A[0*A[2]*A[3] , A[0]*A[1]*A[3] , A[0]*A[1]*A[2]} The C code to this solution will be : #include int main() { int n,i=0; scanf("%d",&n); int A[n],B[n]; int temp1[n], temp2[n]; for(i=0;i=0;i--) { temp2[i] = product; product *= A[i]; } for(i=0;i The time complexity to this solution will be O(n) and the space complexity to this problem will also be O(n). We can fill two arrays: headProduct and tailProduct. Each headProduct[i] == product of A[0..i-1], tailProduct[i] ==[i+1..A.lenght-1]. They can be built in O(n) and the result could be gathered in O(n). Memory demand is O(n) Not commentary nt a[N] = {1, 2, 3, 4}; int products_below[N]; int products_above[N]; int p=1; int p1=1; for (int i=0;i def solve(arr,n): product_arr=[1]*n product=1 for i in xrange(n): product_arr[i]*=product product*=arr[i] product=1 for i in xrange(n-1,-1,-1): product_arr[i]*=product product*=arr[i] return product_arr {{{ If A = {a0, a1, a2, ... an} Construct two arrays called left_p left product and right_p right product: left_p = {1, a0, a0 * a1, a0 * a1 * a2, .... , a0 * a1 * a2 ... * an-1} right_p = {a1*a2*...*an, ....... an-2 * an-1 * an , an-1 * an, an , 1} prod_p[i] = left_p[i] * right_p[i]; }}} O(N) Solution!!! static void Calculate(int[] iArr) { int total = 1; for (int i = 0; i < iArr.Length; i++) { total *= iArr[i]; } for (int i = 0; i < iArr.Length; i++) { iArr[i] = (int)(total * (1 / (double)iArr[i])); } } The answer I post above this uses division. Oops. Here is an answer without division static void Calculate(int[] iArr) { int total = 1; for (int i = 0; i 0) { temp -= iArr[i]; newVal++; } iArr[i] = newVal; } } Sorry, that last one didn't paste properly static void Calculate(int[] iArr) { int total = 1; for (int i = 0; i 0) { temp -= iArr[i]; newVal++; } iArr[i] = newVal; } } Show more responses p = 1 g = 1 for x in nums: g = g* x + p p = p + x return g Way easy with a simple negative exponent var arr = [2,3,4,5] var prod = arr.reduce((a,b,arr)=>a*b) arr.map((x)=>Math.pow(x,-1)*prod) console.log(arr) //[60,40,30,24] I don't know if this is correct. But i think it is. I have done it with python def multiply(numbers,n): total = 1 for x in numbers: if x != n: total *= x return total a = [10, 3, 5, 6, 2] n = 4 prod = [] for i in a: re = multiply(a,i) prod.append(re) - create a binary tree with the values of array as leaf node - each parent is the product of its children - once the tree is formed, for each value/leaf traverse the tree to the top, each time multiplying the sibling -if tree construction time is ignored, this will take logn time for each calculation and nlogn time for all elements int[] array = new int[]{2,3,4,5}; int m = 1; int m2 = 1; int[] array1 = new int[array.length]; int[] array2 = new int[array.length]; for (int i = 0, j = array.length - 1; i < array.length; i++, j--) { m *= array[i]; array1[i] = m; m2 *= array[j]; array2[j] = m2; } for (int i = 0; i < array.length; i++) { if (i == 0) { System.out.println(array[i] + " " + m2 / array[i] + " " + array2[i + 1]); } else if (i == array.length - 1) { System.out.println(array[i] + " " + m2 / array[i] + " " + array1[i - 1]); } else { System.out.println(array[i] + " " + m2 / array[i] + " " + array1[i - 1] * array2[i + 1]); } } Of course, if allow more temp arrays it can be done in one iteration int[] array = new int[]{2, 3, 4, 6}; int m = 1; int m2 = 1; int[] array1 = new int[array.length]; int[] array2 = new int[array.length]; int[] array3 = new int[array.length]; int middle = array.length / 2; for (int i = 0, j = array.length - 1; i = middle) { if (i + 1 != array.length) { array3[i] = array1[i - 1] * array2[i + 1]; } else { array3[i] = array1[i - 1]; } if (j - 1 >= 0) { array3[j] = array1[j - 1] * array2[j + 1]; } else { array3[j] = array2[j + 1]; } } } for (int i = 0; i < array.length; i++) { System.out.println(array3[i] + "===" + m2 / array[i]); } Need help in writing Scala Program for multiplication of 2 elements of array and last element should not exceed 1000. Input Array:(1,3) Output: Array(1,3,3,9,27,243...) #include using namespace std; int main() { int y=1,a[23],i,k,s,t,b[76]; cout >s; for(i=0;i>a[i]; for(i=0;i #include using namespace std; int main() { int y=1,a[23],i,k,s,t,b[76]; cout >s; for(i=0;i>a[i]; for(i=0;i let arr = [1,2,3,4,5] arr = arr.map((el,i)=>{ return arr.slice(0,i).concat(arr.slice(i+1)).reduce((a,b)=>a*b) }) console.log(arr) Show more responses traverse once and store all the product of element . For(0 to n-1) A[i]= products*pow(a[i],-1); One or more comments have been removed. |
See Interview Questions for Similar Jobs
- Software Engineer
- Software Developer
- Senior Software Engineer
- Senior Software Developer
- Business Analyst
- Analyst
- Consultant
- Software Development Engineer
- Associate
- Manager
- Intern
- Applications Developer