Interview goes great

>interview goes great
>developers behave bro-tier
>answer everything they ask without breaking a sweat
>”Well done, user. Now comes the last phase of the interview”
>they wheel in the whiteboard out of nowhere, the room was basically empty
>”uh is that necessary?”
>”Well, we have to examine your coding and debugging abilities on the fly”
>”Write a function that can balance an arbitrary binary tree”
>start sweating profusely
>”I’m sorry... I really can’t do this”
>leave the room, flee in terror and cry

I’m tired of this whiteboard bullshit. As if I will never debug my code or search google for answers. Pff

Attached: B6E12AB3-0C95-4A3C-AA72-AAE4D81D5122.jpg (350x350, 16K)

Other urls found in this thread:

yegor256.com/2017/02/21/say-no-to-google-recruiters.html
twitter.com/NSFWRedditGif

>pre interview going great
>"are you here for the interview?"
>yes
>"what is your name?"

Attached: 1505392260423.png (655x527, 224K)

>balancing an arbitrary BTree
>arbitrary
There's no hope, keep poping the elements and add them to a newly created tree. Then set the old pointer to the given tree to the new tree.

Attached: 1519264861280.png (645x729, 62K)

>whiteboarding section of interview
>trying to finish strong
>can't get answer and realize I'm taking too long
>"why are you not writing anything user?"
>panic
>tell him I'm left handed
>looks at me like I'm retarded
I'm not meant to make it in this world lads.

Attached: 1528699205083.jpg (1305x1265, 495K)

>wheels in the whiteboard
>"EH HEM"
>wheels out the whiteboard

Attached: 1235b.jpg (590x454, 31K)

I know it's arbitrary and stupid compared to your regular day-to-day tasks as a developer but I've been grinding problems on leetcode and watching MIT OpenCourseWare CS algs/data structures videos and I'm doing my onsite at Google & Facebook next week after I just throatfucked my interview at the big daily fantasy company so hard they wanted to hire me right away. I'm no genius either, but it's a skill you can build. If you wanna be hireable in the year of our lord 2018 you have no choice but to play the stupid game. But since no one wants to practice whiteboard interviewing except interview Chads like me, you too can become a interview Chad.

A thread died for this.

DraftKings?

>white board rolls in
>ask why black boards arent better represented in tech interviews
>get hired on the spot

Please tell me this is real

Attached: 1315913196526.jpg (550x539, 45K)

>white board rolls in
>show them the hole where my penis used to be
>get hired on the spot

just do it, for fucks sake

everybody is perfectly aware that you won't be the miracle jesus coder that would solve 30 year old computer science problems on a whim

whiteboard problems exist so they can see you think your way through a problem. if you don't succeed, ok, tell them what you think the problem is and what you'd do "in real life"

all that being said - most whiteboard problems are really not that hard. generally it's first year shit like basic tree or sort algorithms. maybe some data structure stuff. calculating fibonacci numbers or classic fizzbuzz is about as hard a problem as anyone really should be able to do it on the spot

anything beyond that is purely to see you think and apply logic to a problem

>not drawing a big ol dick

>developers behave bro-tier
>bro
Fucking Normies, get out of my technology industry.

Yep.

>most whiteboard problems are really not that hard

Attached: 1528678312193.png (851x846, 573K)

all of those are doable by simply trying to to them
maybe you won't be able to solve them within 2 minutes, but that's totally ok

I'd be very sceptical about anyone who would be able to solve these problems next to instantly and claims he never heard of them before

but i stand by what I said. just fucking try your best - more often than not, you'll be able to solve them, and if you aren't - you can at least communicate what difficulties you're having and what you'd do about them

also, I've done the egg problem once
it's not that hard

Attached: eggalgo.jpg (2083x1482, 140K)

yeah, this. unless interviewers are not forthcoming, they will help you figure out the problem you were having if not employing you. at least that is my experience.

I was once asked to implement malloc, on a whiteboard

>don't have the required skills
>wants job anyways

only americans

Do it then?

this is not the optimal solution. i don't remember the correct one, but it triea throwing the first egg on the 20th floor or something.

seriously? what were you applying for, a phd at Standford?
not that it's not possible but i wouldn't expect more than 5-10% of all programmers to be able to do it at all, much less on a whiteboard and being pressured to do it fast

A local minimum of what?
Sort O(n^2) elements?

local minimum = smaller than all its neighbors (excluding diagonals)

of the points, it's pretty obvious what it's asking
say your matrix is

[5] [7] [3]
[4] [0] [2]
[1] [6] [9]

then the local minimum is (1, 1) indexing from 0

Attached: 600px-Extrema_example_original.svg.png (600x480, 27K)

what do you mean excluding diagonals? that's not anywhere in the problem

it's almost like said, in that matrix 0 is the absolute minimum (because it's the smallest of the matrix); 0 and 1 are local ones (because they are smaller than their neighbors).

underrated

You're probably the 30th person they've interviewed today.

>demand black board for diversity
>interviewer fires himself on the spot
>receive letter of invitation to join board of directors by courier next morning
Life is much easier than you autists make it up to be

kek

The third one got me good.

The optimal solution is to drop each egg (k-1) floors each time, where k is the last number of floors you dropped such that when you drop it 1 floor you get to the top one.

Attached: 41853400_985227715021590_3203635768446681088_o.jpg (1199x1200, 106K)

kek

The best I could come up with was starting at 10 then jumping 10 at a time until it breaks, at which point you revert to the safe 10+1 and jump 1 at a time. That way the least attempts is 1 and most is 19.

>move in front of the whiteboard
>they bring their petit baton blanc out
>they move it in front of their line of sight while watching you in front of the board
>"yup"
>"I see it it too"
>"sorry user, you're deemed too white for our diverse workforce"
>"RAAAAPEEEE HE'S RAAPING ME RAAPPPPEEEEEE"

anyone knows how to solve #3?

It was useless neets and social outcasts who took it over, not the other way around. The bro's are just taking back what was initially theirs.

>I’m tired of this whiteboard bullshit
I hate it when the candidate freezes up, with you knowing they have NO idea what they're doing. It makes it too easy to put their resume in the trash.

With bruteforce simulations or math.

>candidate stands in silence writing code on the board
>"Is everything okay user?"
>10 minutes later, they put the marker down and back away, nodding their head
>"I'm done."
>Their code is completely accurate, the most beautiful implementation I've ever seen
resume goes in the trash

Absolute state of SJW companies.

yegor256.com/2017/02/21/say-no-to-google-recruiters.html

>candidate says nah man I'm not doing that shit
>changes the subject to sports and pop culture
>talk for 45 mins about my fav sport team and GoT
Hired immediately

>pre interview
>interviews to do interviews

Attached: 1521917028609.png (600x420, 254K)

>interviewers are females
You're fucked.

the third one is the easiest one because there's no big O requirement and you can just simulate the situation with random numbers

here's a solution i came up with, disclaimer i'm rusty in c++ and the random number may not be all that random, fucking up with the results. it's just an idea of how to solve it

Attached: problem 3.png (1092x1230, 53K)

seems like a trick question. "rebalancing an arbitrary binary tree" means creating a new tree from scratch. you can rotate a tree until you deem it balanced, but what's the point?

best fit first is quite simple

minima are notoriously hard to compute though

I thought we're supposed to prove it mathematically instead of doing some kind of statistics.

This. Get the fuck out of here you on-the-spectrum cunts.

dunno, this is a programming interview and not a math interview, i'm pretty sure a brute force solution should be acceptable
made if faster by just resetting the initial conditions instead of making a new urn from scratch, also moved the uniform distribution to the class and outside of the functions

yes, i'm still not sure how to even try solving #2 in O(n)

Attached: problem 3.png (877x1369, 46K)

i cried and then i laughed and finally i cried some more

Your simulation is wrong somehow and there is exact answer.
It should be 4/105.

Attached: 1530243605377.png (195x195, 58K)

And what if I don't have a floating point unit?

I doubt it's so small. I think you're a dumb anime poster

Output 4/105 as two ints representing a rational.

no fucking way, prove it

Here's a correct simulation:
import random

def f(r, b):
while r+b > 1:
if random.randint(0,r+b-1) < r:
r -= 1
else:
if random.randint(0,r+b-1) < r:
r -= 1
else:
b -= 1
if r:
return "red"
return "blue"

n = 100000
d = {"red": 0, "blue": 0}
for i in range(n):
d[f(80,20)] += 1

print(d)
print(d["red"]/n)

$ python sim.py
{'red': 3840, 'blue': 96160}
0.0384

Proof left as an exercise to the reader.

Attached: 1529893479538.jpg (1372x1952, 248K)

>interviewing college student for summer job
>ask him if he knows c
>"yes"
>what size is a pointer?
>"uhhhh"

Attached: 1521329212085.gif (280x224, 914K)

Lol this!

Facts.

is it a trick question? It depends on the compiler and is likely to be 4 or 8 on 32 bit or 64 bit system right?

Cool story Snoo

+1

LOL This should be everyomwhere am i right guys? XD

>Only tenth generation+ Americans

I prefer that to some bullshit hypothetical. There's no reason someone with a CS degree can't learn how to implement malloc within a day

lol i found out what was wrong, my bad for calling you a dumb anime poster
>while (get_num_balls() > 2) should be > 1 obviously
I don't know what the fuck went through my mind

idiot. eggs break no matter which floor you throw them down from. you need to break zero eggs to figure this out.

unless you're brilliant it's going to take you hours, only the top programmers will be able to do it on the fly on a fucking whiteboard
and half of those will be able to do it just because they got it as an exercise and remember how they solved it

The first two are very easy and if you can't solve them, please leave Jow Forums immediately.
I bet the third one is also easy but I'm shit at statistics.

thanks for the kek

#2 is non trivial and harder than #3... what's your solution? You can't use gradient descent because that is O(n^2) (proof: a spiral descending path is easy to make and takes O(n^2) time). You can't even use binary partitioning because that's O(n log n).

I was thinking maybe you could scan a line for the smallest element in O(n), to find the local minimum in one axis, then do the same with the other axis, but you aren't guaranteed to find a solution and you have the same issue as with gradient descent.

just think about how you would simulate it

what are these, some kind of MAGIC eggs?!

Don't worry. Someone told me to write down how the internet works, and i started drawing clouds that connected with eachother...

Getting exact solution to 3 is definitely the most difficult.

You can just iterate over the elements of the matrix in any order and check of its neigbors are all smaller. If yes, you have a local minimum. If you ran out of elements without finding one, there is no local minimum. This is O (k*n) = O (n) (k is the number of neighbors, 8 if you can go diagonally, 4 if not).
A slightly smarter way would be gradient descent.

user there's n^2 elements.

That won't work, gradient descent takes O(n^2) time. Iterating over the elements of the matrix also takes O(n^2) (because in an nxn matrix, there are n^2 elements).

Also there is guaranteed to be a local minimum because the numbers are distinct

it's a programming challenge not a math challenge, you're supposed to brute force it

> balancing a binary tree is hard
Guess how I know you never took an algorithms class.
You can either traverse the entire tree recursively or build a new AVL tree from the sorted data. Your choice. Easy as fuck. Just rotate the nodes when they become imbalanced

>he doesn't know

Attached: Screen Shot 2018-09-19 at 12.26.25 AM.png (1798x692, 301K)

Wouldn't a modified binary search guarantee the best running time (log_2(n)), or did I misunderstand the question?

Attached: eggs.png (389x166, 9K)

You only have two eggs.

Oh yeah, I missed that part

void*
malloc(size_t size){
void *a;
Memblock *bp;

for(bp = blocktab; bp->size; bp++){
if(bp->size >= size){
a = bp->addr;
bp->addr += (void*)size;
if((bp->size -= size) == 0)
do{
bp++;
(bp-1)->addr = bp->addr;
}while((bp-1)->size = bp->size);
return a;
}
}
return NULL;
}


something like that

ah yes just crack out that bread-and-butter AVL algorithm that everyone knows by heart

How would you come up with the number of big jumps if the number of floors was an arbitrary number?

Literally the only solution to the whiteboard problem.

you know your field is saturated when interviewers are pulling shit like that

SO.MUCH.THIS!!!!

>startup
yeah... that's a yikes for me

hmmmm let me try #3

n = # of balls
r = # of red balls
b = # of blue balls = n - r


if red ball is picked (r/n chance)
1 chance of removing red ball
if blue ball is picked (b/n chance)
r/n chance of removing red ball
b/n chance of removing blue ball

So for any given ball pick (not counting second pick after the blue ball), there is
(r/n + r/n * (1 - r/n)) chance of removing red ball, ((1 - r/n) * (1 - r/n)) chance of removing blue ball.
reduces to (2r/n - r^2/n^2) and (1 - 2r/n + r2/n^2) (which sums to 1 so we know its correct)

yep, way too hard for me. Not even sure I could do it if those probabilities didn't change over time, but they do, and also nonlinearly. You probably have to model it as a stochastic differential equation or something like that, if that even exists. Or some trick I don't know about. If I had more time I would try calculating the probability than you remove a certain color n times in a row given an initial r and b

that's not a hard proof though. most interviews i've seen have had something more relevant (calculus isn't super relevant for IoT)

MVT is basic bitch shit

It's not even that hard. You literally flip nodes when they become more than 1 level longer than the other branch
You can derive the algorithm on the spot easily. Just a rotate right and/or rotate left.

I have a proposal for the egg problem. It's probably not the best one though.
>building has n floors where n>1 and is a positive integer
>drop egg from the first floor, if it breaks then the task is impossible
>drop egg from top floor (let's assume it breaks)
>drop egg from the n/2th floor if it breaks then proceed to n/4th floor if it doesn't then 3/4 nth floor etc.
basically logarithmic search