>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
>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.
>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.
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.
Dylan Bell
A thread died for this.
Gabriel Sullivan
DraftKings?
Jeremiah Reed
>white board rolls in >ask why black boards arent better represented in tech interviews >get hired on the spot
>white board rolls in >show them the hole where my penis used to be >get hired on the spot
Luis Thomas
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
Ayden Perry
>not drawing a big ol dick
Connor Jackson
>developers behave bro-tier >bro Fucking Normies, get out of my technology industry.
Cooper Taylor
Yep.
Kayden Hughes
>most whiteboard problems are really not that hard
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
Kayden Flores
also, I've done the egg problem once it's not that hard
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.
Jackson Morris
I was once asked to implement malloc, on a whiteboard
Chase Sanchez
>don't have the required skills >wants job anyways
only americans
Levi Reed
Do it then?
Cooper Hall
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.
Austin Evans
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
Chase Roberts
A local minimum of what? Sort O(n^2) elements?
Brayden Gutierrez
local minimum = smaller than all its neighbors (excluding diagonals)
Brandon Allen
of the points, it's pretty obvious what it's asking say your matrix is
what do you mean excluding diagonals? that's not anywhere in the problem
Anthony King
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).
Lincoln Ward
underrated
Charles Barnes
You're probably the 30th person they've interviewed today.
John Phillips
>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
Elijah Jones
kek
Jaxon Sanders
The third one got me good.
Ayden Mitchell
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.
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.
Justin Hall
>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"
Luke Cox
anyone knows how to solve #3?
Elijah Fisher
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.
Lincoln Edwards
>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.
Aiden Ramirez
With bruteforce simulations or math.
Jonathan Cruz
>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
>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
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
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
Jose Nguyen
I thought we're supposed to prove it mathematically instead of doing some kind of statistics.
Luke Hughes
This. Get the fuck out of here you on-the-spectrum cunts.
Caleb Barnes
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)
I doubt it's so small. I think you're a dumb anime poster
Gavin Morris
Output 4/105 as two ints representing a rational.
Jacob Taylor
no fucking way, prove it
Aaron Scott
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
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?
Jacob Myers
Cool story Snoo
Angel Baker
+1
Jonathan Mitchell
LOL This should be everyomwhere am i right guys? XD
Nolan Baker
>Only tenth generation+ Americans
Robert Garcia
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
Adam Lopez
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
Lincoln Flores
idiot. eggs break no matter which floor you throw them down from. you need to break zero eggs to figure this out.
John Johnson
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
Jason Flores
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.
Landon Harris
thanks for the kek
Robert White
#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.
Zachary Edwards
just think about how you would simulate it
William Rivera
what are these, some kind of MAGIC eggs?!
Andrew Lewis
Don't worry. Someone told me to write down how the internet works, and i started drawing clouds that connected with eachother...
Ryan Jackson
Getting exact solution to 3 is definitely the most difficult.
Joseph Thomas
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.
Leo Moore
user there's n^2 elements.
Jonathan Reed
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).
Lucas Perez
Also there is guaranteed to be a local minimum because the numbers are distinct
Caleb Butler
it's a programming challenge not a math challenge, you're supposed to brute force it
Jaxon Anderson
> 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
ah yes just crack out that bread-and-butter AVL algorithm that everyone knows by heart
Nathaniel Sullivan
How would you come up with the number of big jumps if the number of floors was an arbitrary number?
Christian Murphy
Literally the only solution to the whiteboard problem.
Leo Miller
you know your field is saturated when interviewers are pulling shit like that
James Baker
SO.MUCH.THIS!!!!
Aaron Morgan
>startup yeah... that's a yikes for me
Brandon Fisher
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)
Caleb Thompson
MVT is basic bitch shit
Brandon Cook
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.
Chase Williams
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