![]() |
This see who the smart ones are
Question: Given an unsorted array of integers, find any 3 numbers that will add up to 100. For example, if the array has -77, 55, 22, 0, 2, and 155, one answer would be -77, 22, and 155.
|
Looks like no smart people here
|
The smart ones avoided wasting their time on something they have no need of. ;)
|
Step 1: Randomly pick 3 numbers from the array
Step 2: Do they add to 100? If Yes, DONE. If No, go to step 1. What do I win? |
Quote:
|
I gave the answer is pseudo-code. You didn't specify it needed to be in particular language. An algorithm is generally acceptable in computer science as anyone with a basic understanding of a language can easily convert it.
|
It involves numbers... I generally avoid anything involving numbers. Words are my thing. I can barely add up using a calculator :D
|
It reminds me of college exercises and Facebook Hacker Cup.
PHP Code:
|
Is it a homework question? :p
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
or not...:D |
When I google the question, I find that it's a question that Facebook has asked while interviewing potential engineers. There are also lot of potential solutions, including the one ForumsMods posted above (which is an algorithm called 3SUM, http://en.wikipedia.org/wiki/3SUM). I think the point of the question is recognizing that the obvious solution (adding together every combination of 3 numbers) is not an efficient algorithm compared to other ways of doing it. I think if I wanted to hire a good software engineer I might ask some similar questions, but I'd probably wait until the interview or at least pick one that couldn't be solved so easily using a search engine.
|
What ALSO floats in water?
|
Have anyone give the right answer yet? I will be honest, it is even hard for me too but Im not sure about the 155...
|
All times are GMT. The time now is 04:45 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|