Thread regarding Qualcomm Inc. layoffs

You are given an array of n unique integer numbers 0 <= x_i < 2 * n

You are given an array of n unique integer numbers 0 <= x_i < 2 * n

Print all integers 0 <= x < 2 * n that are not present in this array.

Example:

find_missing([0]) = [1]

find_missing([0, 2, 4]) = [1, 3, 5] # because all numbers are [0, 1, 2, 3, 4, 5]

find_missing([]) = []

find_missing([0, 1, 4, 5]) = [2, 3, 6, 7] # because all numbers are [0, 1, 2, 3, 4, 5, 6, 7]

Quirks are about requirements:

Time complexity O(n) - BUT there should be some fixed constant C independent of size of input such that every element of array is written/read < C times, so radix sorting the array is a no go.

Space complexity O(1) - you may modify the initial array, BUT sorted(initial_array) must equal sorted(array_after_executing_program) AND you can't store integers outside range [0, 2n) in this array (imagine that it's an array of uint32_t).

by
| 1297 views | | 14 replies (last February 10, 2016) | Reply
Post ID: @OP+FS2UFBc

14 replies (most recent on top)

@giu hahahaha

by
| | Reply
Post ID: @mzf+FS2UFBc

&giu hahahah

by
| | Reply
Post ID: @vor+FS2UFBc

when will hackerrank copy paster strike again? Is OP busy solving P=NP problem?

by
| | Reply
Post ID: @fin+FS2UFBc

To the guy who repeats: Companies do this because if it's already out there, they can't patent/copyright/TM it and claim it as IP for licensing purposes.

by
| | Reply
Post ID: @fcv+FS2UFBc

OP is still in QC, revising CS notes and preparing for interviews. Yes, he graduated from CS. His name starts with N.

by
| | Reply
Post ID: @eaa+FS2UFBc

Better problem: you are given a financial time series starting from $82 down to $43. Assuming memory is foggy at best, calculate the optimal times to destroy shareholder value via financial engineering

by
| | Reply
Post ID: @zrd+FS2UFBc

Dear OP, you should get a life and maybe a girlfriend. I feel sorry for you.

by
| | Reply
Post ID: @xdl+FS2UFBc

Wow OP took a computer science class. Congrats!!!!

by
| | Reply
Post ID: @tia+FS2UFBc

Employers should test how well you can Google to find a solution instead of writing something from scratch. SW development is now about making something new with what's already out there, and there's so much out there.

by
| | Reply
Post ID: @hbq+FS2UFBc

Why bother? You can Google the answer in < 2 min. Why do companies pay people for weeks and months just to solve problems that have already been solved and are just a Google search away? Now, if you can show a solution to one of the, so far, unsolved problems, pick any one, and we might be able to use you.

by
| | Reply
Post ID: @wsq+FS2UFBc

Why bother? You can Google the answer in < 2 min. Why do companies pay people for weeks and months just to solve problems that have already been solved and are just a Google search away? Now, if you can show a solution to one of the, so far, unsolved problems, pick any one, and we might be able to use you.

by
| | Reply
Post ID: @ajo+FS2UFBc

Why bother? You can Google the answer in < 2 min. Why do companies pay people for weeks and months just to solve problems that have already been solved and are just a Google search away? Now, if you can show a solution to one of the, so far, unsolved problems, pick any one, and we might be able to use you.

by
| | Reply
Post ID: @dij+FS2UFBc

Why bother? You can Google the answer in < 2 min. Why do companies pay people for weeks and months just to solve problems that have already been solved and are just a Google search away? Now, if you can show a solution to one of the, so far, unsolved problems, pick any one, and we might be able to use you.

by
| | Reply
Post ID: @qoy+FS2UFBc

Why bother? You can Google the answer in < 2 min. Why do companies pay people for weeks and months just to solve problems that have already been solved and are just a Google search away? Now, if you can show a solution to one of the, so far, unsolved problems, pick any one, and we might be able to use you.

by
| | Reply
Post ID: @giu+FS2UFBc

Post a reply

: