just another scala quant
  • just another scala quant

Inverting Binary Trees Considered Harmful

6/11/2015

 
Picture
Picture
[Inverted Tree © 2006, John Opsopaus]






Man, interviews in the Valley have truly gotten fucking awful.There is no other ritual that is as thoroughly dehumanizing, utterly useless, tediously time-consuming, here's-a-banana-dance-monkey-dance freak-show of zero predictive value, as the supreme haze-fest that goes by the name Silicon Valley Casting Couch.  And we are all complicit - engineers in startups,  big corps, and finally, the candidates themselves who voluntarily subject themselves to this shameful farce.


Back when I was working at Twitter, my boss constantly interviewed at firms outside Twitter. He also encouraged us to interview. His motto was - you never know what's out there. So if you are invited to an interview, take the afternoon off on a Friday and go. You might learn something valuable. So even though I had a really sweet gig at Twitter and had no intention of changing jobs, I would politely answer phone calls of desperate sounding recruiters, and take the Muni to show up at the interview, roughly once every 2 months, on Friday at noon when the drinking starts at Twitter ☺

Know what ? He was absolutely right. Every one of those interviews taught me something truly valuable - mostly that I was one lucky SOB to have a gig at a place like Twitter :) Honestly, most of these other companies were truly dysfunctional on so many levels I could write a whole book....these were companies of all shapes and sizes - Blackrock, Wealthfront, Stocktwits, Premise, OPower, Glassdoor, a bunch of YC companies that shall not be named for fear of perpetual backlash and eternal banishment from the kingdom of HN :) ,  and a dozen others...

At all these companies,  I would be ushered in politely and a C-suite guy would deferentially explain the business problem that was right up my alley. Those days, Scalding was the hottest tool in the toolbox. Everybody had (or thought they had) a Hadoop ETL problem, and Scalding was the key to their problem chest.  Scalding is this cute little Scala DSL that was invented at Twitter, and got a lot of traction in the absence of Spark, because it was a rock-solid elegant FP alternative to the ugly (as in ugly-as-Pig :) task of authoring map-reduce jobs. I love Scalding, and take pleasure in subjecting Scalding to perverse computation tasks it is thoroughly unsuited for, like perceptrons & portfolio management :) I also do useful shit with it, for which I got paid, but that stuff is quite boring. So anyways, all these managers wanted me to come on board asap & code Scalding jobs for them. Sure, why not ? Well - wait a minute...first, we want you to interview with the engineering team to see if you'd be a right fit. So that's how it begins.

You are then ushered into a room with the programmer's worst nightmare - a blank whiteboard.
For the next 3 hours, you will be subject to a hostile tete-a-tete by 3 different engineers, or sometimes 6, because SV has this concept of a shadow - this shadow engineer is sort of a trainee-in-the-wings, learning how to poke and prod you - the programming sample that has shown up on the company petri-dish, so tomorrow he could independently interrogate new programmers who dare walk into THE ROOM WITH THE WHITEBOARD, entry to which was forbidden to all except the ones with perfect SAT scores.

The first programmer with/without a shadow walks in. He's quite annoyed, because he was neck deep in jira or git or debugging some hairy stack-trace on eclipse, and he's been unceremoniously yanked off to interview YOU - the new dude, who has no fucking idea how things really work here. Well, he must show YOU your place. You lowly worm, how dare you interrupt the lovely horizontal scroll-through of nested exceptions emerging through the anonymous class OOM-ing inside Spring's MetaFactoryAbstractContainer ? You shall pay. Dearly. Tell me, noob, how the fuck do you invert a binary tree ? 

Now, I was never asked that particular question. The Blackrock guy only wanted me to tell him EXACTLY how Java/Scala computes the hashcode of a String. 
Now, if you must know, this is how it EXACTLY it computes the damn hashcode -
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]

So it exponentiates 31 by one less than the length of the string and multiples that with the first character's ascii, then exponentiates 31 by two less than the length of the string and multiples that with the second character's ascii, and so on and so forth, and sums the whole mess. And I'm supposed to know this.

Now, in his defense, computing the dot product of the string with a random prime vector is a well known Universal Multiplicative Hash Function, but forgive me, father, for I did not pay much attention to this invaluable nugget in my Algorithms 101.

Was it the Wealthfront guy who wanted me to write a unit test for Pascal's triangle ? Or was it an integration test, I forget ? Only he didn't tell me in so many words. He said the first row was a 1, and the second row was a 1,1. The third a 1,2,1 etc. So now write a function that spits out the nth row. Being a math major, I wrote out the recurrence that would generate Pascal's triangle. He now says, ok, how do you unit test this ? Unit what ? You know, how do you test whether the function is coded up correctly? Now, am not what you call a TDD guy - I have written a unit test or two, but it seemed so silly to unit test a perfectly valid math identity, so I innocently asked him if I had gotten the recurrence wrong, and I believe I was a no-hire at that point.

The Glassdoor guy was a former Googler, so he was like - wait a minute I read this really cute puzzle last week and I must ask you this - there are n sailors and m beer bottles and something to do with bottles being passed around and one of the bottles containing a poison and one of the sailors being dishonest and something about identifying that dishonest sailor before you consume the poison and die. I truly wished I had consumed the poison instead of laboring through that mess.

The OPower guy said they had a ton of problems where they will be using Scalding, so I asked him what they are doing in its absence. He said Oh we pojo it. Then he said pojo this and pojo that, and soon I was drowning in pojos, so I asked, Sorry, what exactly is a pojo ? Now, bear in mind I am a Scala programmer and haven't touched Java in ages, and they knew that. Their whole pitch was they wanted to inject some new Scala blood into their tired Java veins, and that's why I interviewed there. So the guy is agape, and says, you don't know what a pojo is ? When was the last time you wrote Java ? I was like, a decade ago, back in Goldman...seems like a lifetime now. So he says, write a map-reduce job in Java on the whiteboard correctly and the job is yours. Now, I tell him, dude, I don't write Java at all - this is a Scala gig & that's why I'm here etc. He says, yeah, ok, but, you did write Java at some point in your life, so think back and write. Now I am like, how the fuck does it go - public static void main open brackets is that square bracket or paren...int argc char star argv no fuck that's C how do you do a char* in Java oh I know argv[], honestly, I've written thousands of lines in Scala and Java's really not my thing, and the whole point of Scalding is to not think so hard and just grab a TypedPipe and compose pipe.map{foo}.reduce{bar}.write{sink}, why would anybody want to map-reduce in Java and at this point, I have lost the job because, the recruiter tells me "you are too passionate about scalding and don't know what a pojo is".

The [redacted] YC startup had a really cool contest to which I submitted a greedy algorithm solution coded up in Scala. I was promptly flown down to Mountain View, wined & dined, and then asked to code something in Ruby. Being completely unfamiliar with the language, I got nowhere. They sent me a polite rejection that said Scala was a non-starter because it was such an ugly language, and everybody in the Valley uses Ruby and Python, because that's what every YC start-up uses. Then that tautological start-up died and its co-founder now hangs around on the Scala stackoverflow channel :)

Ironically, the one place where I was hired with zero interviews was a cozy little outfit on the east coast called GS. So this was way back in the late 1990s, when I was a consultant from Sun Microsystems, showing the folks at GS how to build a trading system inside an applet. The whole premise seems laughably silly, but those were the days when Netscape was one of the largest internet companies out there, and GS wanted their trading applet to run on Netscape Navigator, or Communicator or whatever the hell that particular browser was called. Goldman in those days had a very strong systems presence, for it had poached a bunch of C++ compiler guys from Bell Labs. These were strong theoreticians, one of whom wrote his own "trading language", a sort of C++ DSL which would spit out dags as output. Now, there was a markup language called "HTML" that these guys knew nothing about. Matter of fact, they knew practically nothing about Java or applets, because trading systems then were proprietary software distributed on floppies and CD-ROMs. The internet was too new, and nobody thought you could trade equities over the internet inside an applet. So I took this directed acyclic graph that the C++ DSL produced, and wrote a straightforward recursive descent parser in Java that converted the dag to a nice looking tree in HTML. I then sent that chap an email with a link. When he clicked on that link, his Netscape browser window opened and showed him his dag in a panel. Straightforward html shit. That chap went gaga. He was an MD and had great clout, so he calls up Sun Microsystems and says, we have hired your consultant! He is now going to work for us! Now, Sun doesn't like poaching, but its GS, so the legal folks on both ends got involved & sorted it out over the weekend. Next Monday, I was no more a consultant. I began working at GS as a regular Goldman employee. With zero interviews. All because I could parse a goddamn binary tree.


Picture
Zero Tolerance
6/11/2015 12:24:51 pm

Spot on. Interviewing as it is practiced today has less relevance to finding good workers then astrology has.

Ryan
6/14/2015 05:57:03 am

Yeah, my personal method for interviewing (when I was doing that a few years ago) was: 1) ask a small list of basic OOP and programming questions to make sure they have a grasp of basic theory. 2) Give them a laptop w/ internet access (google totally allowed) and a quiet room for about 90 minutes to a) fix a simple program that I wrote and then intentionally broke and b) write a simple program from scratch which I'd included a detailed explanation of. The good ones solved both coding problems in ~15-30 minutes.

If we used a whiteboard it was for them to answer a couple SQL questions, because SQL is easy to whiteboard.

Maybe I'm weird for thinking this, but I feel like if you're being asked to code on a whiteboard, you should (with few exceptions) just walk out of the interview. If they want you to produce/fix code, they need to give you a real environment to do it on.

Alex
6/14/2015 11:47:50 pm

If asked to code on a whiteboard, I would leave the room, look at their devs working and get back in. If they asked why I left, I'd answer to check if their devs use whiteboards to code.

Paul
6/14/2015 09:06:03 pm

To be honest I have one question which is important - talk about the side project they are working on. If they are passionate about that, then there is a good chance they will be about their day to day job.

Kirk
6/14/2015 10:32:55 pm

My biggest rule of thumb. If they don't have a computer at home, they are not getting a programming job!

John
6/15/2015 01:14:29 am

What if a candidate isn't working on a side project? Maybe he or she has kids or family issues that limit what can be worked on outside of work.

Arindam
12/19/2015 06:29:18 am

If the person has kids / family, he has points docked. :)

MJK
6/11/2015 01:04:56 pm

You know this is exactly how Twitter interviews candidates now, right? They trained up the whole engineering org on it, and shamed everyone into compliance. Binary-tree problems are specifically banned, though.

l1x link
6/11/2015 01:06:38 pm

Ironically though, Twitter (and Twitch for example, what is wrong with all the companies starting with t???) is famous about having single blow interviews. They ask you some question and the solution takes maybe an hour if you are extremely familiar with the subject, but if you not maybe 2-3 hours. You got 20 minutes. Kthx bai. I never understood that. Interviews should be about finding out what is the best of the the candidate. A single blow interview especially when the candidate communicating that she is not familiar with the subject (as the author could not write Java MR, btw. I don't blame him, I don't do java without an IDE either) is stupid. Another stupid interview category: single language or nothing. Few weeks back I interviewed with a company and the guy said I can use anything. I asked bak are you sure? He said yes so I went I solved the problem in Clojure. After the interview I followed up, simplified my solution to a single function with few lines only.

Feedback: I am not enough senior Java programmer. These sort of things just show you how much incompetent some of the startup scene in terms of hiring.

Nice writeup though!! Thanks for sharing.

Harald Glatt (hachre)
6/11/2015 01:17:43 pm

hahahahahah if anyone would ever pull one of these out I'd leave the room laughing....

Vik
6/11/2015 01:24:23 pm

Hah - I'm glad I read this - I have an interview tomorrow and it's bolstered my confidence oddly :)

‘Silicon valley’ really needs to get a life or more importantly a change of title – the title sets the stage for the ridiculousness

Dawn Tasque link
6/11/2015 03:07:58 pm

This is a cargo cult. Google does it, so it must be The Right Thing.

There is another reason to go out interviewing: once in a while, you run into someone with a clue in an otherwise clueless company, and then *you* can hire *them*.

SJ
6/11/2015 04:01:08 pm

Hi Dude,

Great post, you should name and shame those HN companies man. Don't be shy, that is the only way the system will ever change. I liked your writing style - enjoyed it truly, keep writing more often!

SJ

thinkingfish
6/11/2015 06:00:16 pm

1) Your boss is awesome, esp. his shoe collection.
2) Interview training for the most part is BS, but that's what happens at Twitter now.
3) We suck at interviewing because the practice of software engineering is often carried out at a laughably/scarily low standard. So we cannot trust anybody or anybody's past experience.

steve
6/11/2015 10:33:12 pm

Why is this so hard? Just talk shop. Pretend you already hired them and just interact.

What could possibly be easier than that?

Herc
6/14/2015 09:52:26 pm

Amen to that!

Dr. UNIX
6/12/2015 12:40:33 am

It's very unfortunate that these companies treat interviews this way. They forgot that an interview is a opportunity to sell the company to the interviewee.

You can't be very intelligent if you let someone treat you this way and agree to work for them. Having "Google" or "Apple" on your resume is not worth that kind of anguish. Thousands of people have and are working for Google, Apple, etc. I can hire one at anytime. It's not an small exclusive club or gold star on your resume.

eigenfunc
6/12/2015 09:35:48 am

I dreaded these kinds of interviews, but the few I had were not so bad. They had less (or no) algorithms puzzles, and if they did, they were somehow related to the job, or they were given as homework. One offered to let me do a project of my choice using methods similar to what they use (though I had to bail on that due to other companies' deadlines). A couple of them were almost entirely about talking shop on their current problems, discussing previous projects, or behavioral questions.

johri
6/12/2015 05:39:07 pm

so what according to you should be considered an ideal way to interview or hire.

If I am in startup I normally lean on referrals people dont refer folks they dont want to work with. There are instances where they have even proven the interview panel wrong (in the long run).

ftb
6/14/2015 05:28:06 am

so the real question would be how you got into twitter :p But from what you've written it sounds like you have a ton of experience so I can imagine you get in via your past projects/jobs and qualifications. As a student finishing his degree soon I'll probably have a lot of fun in that interview hell just as you except I'll have to pass at some point.. :(

Bob Dole
6/14/2015 02:05:29 pm

It's weird to me how many interviews these days feel aggressive. Not just adversarial - I understand that, even if I don't think it's necessary.
Aggressive, like the interviewer sees your application as a challenge for dominance.

If he lets you into the company you might disrupt his beautiful architecture. If he lets you in without forcing to you appear ignorant at least once, you're certain to disrupt it. Time after time, I've had interviews go off the rails and into topics unrelated to the job or my resume until I admitted ignorance. As soon as I did, we were right on to the next question and back on the topic of the job (after a few smug remarks about my failure to know obscure technique X).

Certainly, interviews in the valley are stupid and uninformative. What really confuses me is how nasty many people make them.

Stoo
6/14/2015 06:23:59 pm

So true, even in Europe. I interviewed for Amazon a few years ago. I've got 25 year's experience including heading up the architecture / design team on a $100M+ project. So I end up talking to some team lead at Amazon on the telephone.

Me: What processes and toolsets do you use?
Him: Each team chooses their own.
Me: Doesn't that cause chaos when team members move around?
Him: -- meaningless drivel -- followed by "solve fizz bang" (this is on the phone)
Me: I don't think that's appropriate to my grade and experience.
Him: What's the subversion command for x?
Me: How would I know, I use Tortoise, if I need to know that there's this thing called the instruction manual.

Our mutual email rejections crossed in the ether.

I am sick of the self justifying zealot developer mentality.

I'm currently a CTO and believe me, we do not use that sort of bullshit at interviews. Show me you know what you're talking about and have a healthy interest in the field and you're in.

ftb
6/14/2015 07:13:41 pm

These kind of replys make me really worried.. I'm just a student currently looking for a international internship. I have some private projects, some practical experience in a part time student job and I think I am a good programmer compared to the average student. Yet I still have a live.. how on earth am I EVER gonna get an internship if even experienced developers think the process is utter shit...
Maybe you should tell me the company in which you're CTO :D You're definetly of the rare kind of people who have a healthy attitude towards employing new people...

Chug
6/15/2015 10:21:20 am

Go find an open source project doing the kind of work you like. Introduce yourself and join the community. Start making contributions. Then everyone who uses that project gets to know you. Earn commit rights and you become valuable to companies who use that open source project as the basis for their business.

For example, if you like working with audio hang out at Audacity. Virtualization? try Docker. Anything at Apache. Internet of Things? maybe Altair, Smarthome, or OpenIoT. The list is endless.

This is easy for me to say but some projects have steep learning curves for somebody just starting out. Even modest projects have pooled the shared mind power of many really smart people and have advanced code and design. But don't be deterred -- jump in and give it a shot!

Chris
6/15/2015 02:59:54 pm

Nah, relax. In fairness, you might have passed that interview. The person you're replying to has expectations that may differ from yours. For example, I don't find those questions offensive at all. Some companies just have much less formal structure than others.

"I don't think that's appropriate to my grade and experience" -- instant fail. I don't think it's appropriate to take that kind of attitude. I've seen too many "software engineers" who can't actually write code. At my company, managers are expected to be able to understand code, and first-level managers are expected to write it. I don't think it's unfair to ask anyone in a technical position to prove that they can write basic code (and fizzbin is incredibly lame, basic code), even if they won't be doing much of it.

You cannot, as an interviewer, take the applicant's resume and background on faith. Your company can't afford it.

Stoo
6/15/2015 09:31:26 pm

@Chris

>"I don't think that's appropriate to my grade and experience" -- instant fail. I don't think it's appropriate to take that kind of attitude

I'd already aced all their tech tests. I've published books and magazine articles. When you're being interviewed for a senior position you do not relish being treated like a 12 year old by the interviewer. That's why I told them I wouldn't be proceeding.

You could say the process worked - we weren't suitable for each other. But can you really? Maybe that's not what it's like inside? A totally artificial interview process like that doesn't reflect reality.

MigMit link
6/14/2015 08:49:46 pm

So... what's so bad about these interviews? I mean, in every instance they've correctly identified you as something who is not a good fit for them. Also, it became quite clear to you that they are not a good fit for you. That seems to be extremely efficient. Sure, this guy with his Ruby startup is stupid; but do you honestly believe things would be better if you were hired? He would still be stupid and his startup would die, leaving you jobless.
I do agree that inverting a binary tree is not a good question though; inverting a string is better. On one of my previous jobs we used that as a filter, allowing candidates to do that at home before actually interviewing them; you won't believe the "quality" of code we were getting. My personal favorite is this one solution, which, after compilation (successful!) we couldn't find the resulting .exe file. Turned out, an antivirus thought this .exe was malicious and quarantined it before we could take a look. No wonder, since the program started with `int main(char * StringToReverse)`.

Dr. UNIX
6/15/2015 12:48:10 am

These types of interviews are bad because they produce too many false negatives. They're not only routing out the incompetent, novices, and bad fits, they are preventing a majority of good, solid, versatile, and intelligent people from getting the job. What they end up with is the one dimensional, the specialized, submissive, and probably nutty employee.

MigMit link
6/15/2015 01:34:03 am

That requires more evidence. A very smart Scala programmer is not necessarily a good fit for a Ruby startup — especially if he is not willing to switch to Ruby.

More sensible approach would be to switch the whole startup to Scala; but that is not about interview process. The process seems fine; it's the actual product of the company is shit.

Pojo?!
6/14/2015 11:18:08 pm

WTF is a pojo?!

Mocha Java
6/14/2015 11:49:45 pm

POJO = Plain Old Java Object.
I was once interviewed by 3 "hostile" engineers at an HMS contractor here on the East Coast. One guy puts a dynamic C++ loop on the board and asks me if it'll compile. I looked it over, and said, probably. He got that "gotcha" look and said, no, it doesn't, but then he just couldn't resist. He had to tell me the story. He said: don't worry, I showed this to Stroustroup at a conference, and he thought it would compile, too.
Didn't get the job because I was "too inexperienced". Imagine that.

MigMit link
6/15/2015 12:26:34 am

Well, I remember being asked the same thing. Here is the code: would it compile? I said yes, interviewer said no. I've pulled out my iPad, ssh'ed into my home computer (which has gcc) and proved him wrong.

Got the job.

chris
6/15/2015 01:16:58 am

I liked the ending of your story, I like happy endings :).

rents
6/16/2015 01:02:20 am

So dude,
don't tease with a puzzle unless you know the full problem stmt?

by chance, remember the exact puzzle?

ttyrueiwoqp
6/20/2015 05:14:53 pm

Rofl, dude you are so funny

Barry
7/19/2015 06:38:31 am

The ironic part is, many of those companies ask this kind of question rarely apply those things in practice. Seriously, I am always curious when this is the last time you worked with data structures other than than a list or hash table.

rick link
11/11/2015 02:36:24 pm

well, that helps me feel better about my interview methods. I typically ask questions to validate that their resume isn't BS, ask some questions to understand how they approach problems (whiteboard is fine, but pseudocode is acceptable), and attempt to ascertain team fit -- passions, projects, not an asshole, are they thoughtful or careless, etc.

Abhinav Maurya
11/13/2015 12:05:01 am

Scala is ugly?!!! That guy must be retarded or unfamiliar with Scala.


Comments are closed.

    Archives

    April 2016
    March 2016
    December 2015
    June 2015
    May 2015
    August 2014
    January 2014
    December 2013
    September 2013
    January 2013
    December 2012
    August 2012
    June 2012
    May 2012

Powered by Create your own unique website with customizable templates.