Favorite Technical Interview Questions?

That one can be solved in log(n) time.

Well I'm sure if somebody plonks that solution on the board the follow up question is going to be "but what if I have a list of 3 million items" and then you'd have to go do some more clever stuff like checking the value of the middle (pivot) etc. I'm sure you have an even better way :p

I was really just passing through the thread and responded without thinking it through. I hate these type of questions anyway.
 
C#:
int[] A = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18 };
Something along the lines of check middle value, if correct then check middle of right side, if not, check middle of left etc. binary search basically.
 
Something along the lines of check middle value, if correct then check middle of right side, if not, check middle of left etc. binary search basically.
Exactly...

Here's a simple O(n) approach in F#:
C#:
let findMissing xs =
  let n = List.length xs
  n*(n+1)/2-List.sum xs

Here's a simple O(logn) in F# using recursion.
C#:
let findMissing xs =
  let l = List.length xs
  let rec find n f =
    if n = l || n = 0 then 0 elif n <> xs.[n] then n else find (f n) f
  find (l/2) (fun x->x-1) + find (l/2) (fun x->x+1)
One could improve on the computing time; if faced with a much larger sequence; using local threads or network of computing nodes;
...by for example splitting the search between a "n quantity of actors"

FYI; a slightly more challenging variation on "find missing number" would be to "find missing number in an arithmetic sequence"
 
Last edited:
Well I'm sure if somebody plonks that solution on the board the follow up question is going to be "but what if I have a list of 3 million items" and then you'd have to go do some more clever stuff like checking the value of the middle (pivot) etc. I'm sure you have an even better way :p

I was really just passing through the thread and responded without thinking it through. I hate these type of questions anyway.

I can’t think of anything better algorithmically. In terms of implementation though: for small N, one could use vectorization to scan the array in parallel. For large N, doing the pivot/binary/search while prefetching the future possible cache-lines may improve performance. Also, starting off with a binary search and falling back to a vectorized linear search when the pruned range is small enough, would give you the best of both worlds.
 
Last edited:
One thing I will say is that I'm glad I'm out of South Africa, where there is no such thing as a back end developer and everyone is a full stack developer.

"What does the viewstate variable in ASP.NET do? What would this line of Javascript actually do?"

Etc etc. I don't mind the use of web technologies such as REST for inter service communication, but front end is the pits.
 
That one can be solved in log(n) time.
You seem to be working for one of the big 6. I did some interviews with one of those recently where time and space complexity was important.
 
You seem to be working for one of the big 6. I did some interviews with one of those recently where time and space complexity was important.

I don’t, but worldwide this is important for anyone who develops or even uses algorithms.
 
Our company doesn't use those automated code testing things - apparently we found that the test results don't necessarily correlate with whether someone is a good hire.

In other words, someone who fails a Codility test is not necessarily a bad hire - they just failed the test.

If you are dealing with a recruitment agency and one of their clients sends you a TestDome or HackerRank test, and you fail this test, not only will you not get the job but you will never hear from the employment agency again.

They all put such weight on these tests that failing one literally means they black flag you from their system and you will never be able to deal with them again.

Failing a HackerRank exam puts you in the same category as a pedophile or ISIS terrorist.
 
If you are dealing with a recruitment agency and one of their clients sends you a TestDome or HackerRank test, and you fail this test, not only will you not get the job but you will never hear from the employment agency again.

They all put such weight on these tests that failing one literally means they black flag you from their system and you will never be able to deal with them again.

Failing a HackerRank exam puts you in the same category as a pedophile or ISIS terrorist.

Depends on if the agency administers the test or if the company that wants to hire you does.

I failed a test for a company called Maven, but the agent still deals with me. Not that I'm looking for work, but when I was, failing that interview didn't mean he wouldn't deal with anymore. I think it helped that, around the same time, I had passed some other first round interviews, with this same agent. So he knew from his other clients that I was good.
 
Top
Sign up to the MyBroadband newsletter
X