r/programming • u/mobby1982 • Oct 30 '13
I Failed a Twitter Interview
http://qandwhat.apps.runkite.com/i-failed-a-twitter-interview/96
u/norkakn Oct 30 '13
Why does he think that he failed due to that answer? Only a silly interviewer will expect people to solve riddle questions. It tends to be much more about how someone works through the unknown than if they end up at an place.
398
u/WhisperSecurity Oct 30 '13 edited Oct 17 '15
If that's the case, then the majority of interviewers are silly.
This is human nature. When you ask puzzle questions, you cannot help but be impressed with the people who get the answer, and unimpressed with the people who don't.
But that's not how intelligence works. Smart people can solve puzzle questions in a couple hours, with a compiler, starting with an easily codeable but inefficient solution and working towards an elegant one in iterations. Smart people solve things right away when they get lucky. And the more nervous they are, the less likely this is.
And yet everyone seems to interview this way:
Fly the candidate, economy class, to an unfamiliar city. Make sure the flight arrives late at night.
Don't have him met at the airport. Instead, get him a rental car (bonus points for no sat-nav), and make him find his way to the cheap hotel.
Let him lie awake for a couple of hours listening to the gasoline-powered air conditioner sucking all the moisture from the air, in the process of cooling the room from 85 degrees F to 84.5 degrees F.
Let him get a few fitful hours of sleep.
Have him check out of the hotel upon arising, because he flies out directly after the interview.
Have him find your building, and check in at the front desk, be handed off to an HR flack, and walked upstairs.
Stick him in a conference room for 6-8 hours.
Rotate through a bewildering array of engineers, project managers, and technical leads, in no discernible order. Have each one ask his favorite whiteboarding puzzle question, or an architecture design problem related in his own work in an infrastructure the candidate knows nothing about.
Be sure to leave it completely unclear which of these people are his prospective co-workers, and which are simply people who were unable, due to lack of political clout, to avoid being the extra body in an interview loop.
Change gears frequently and unpredictably between social challenges (talking about his background, meeting new people, establishing rapport), technical challenges, and intelligence tests and puzzles.
In general, avoid allowing any similarities between the interview process, and the tasks that process is hiring for (software engineering).
Have the day's last engineer dump him in the lobby, confused as to whether or not he's expected to wait for someone else, or get in his cheap rental car and try to find the airport.
If you plan not to make an offer, NEVER CONTACT THE CANDIDATE AGAIN. Don't send him a quick "no, thanks". Don't even reimburse his incidental travel expenses (This means you, Bloomberg). And of course don't provide any helpful feedback which would allow him to improve. Just get him out of the building as quickly as you can.
If you do make an offer, wait a month before extending it, then give him three business days to decide. If he demurs, give him four, and act like it's a big concession.
The inescapable conclusion is that interviews, for both parties, are a bit like rolling dice. Unless someone is totally unqualified, or totally overqualified, what you're measuring is whether your guy had a good day or not.
Evaluating developer candidates is a bit like managing software projects... there's a lot of theories floating around, but none of us really knows how to do it.
58
u/WhyIsTheNamesGone Oct 31 '13
This, while over-the-top, accurately describes my interviewing experience. I was actually able to iterate from the "crappy-but-obvious" solution to "mathematically optimal" in a matter of minutes, talking aloud as I went. They accused me of cheating (somehow) and threw me out immediately. What?
18
12
34
u/UncleOxidant Oct 31 '13
Smart people solve things right away when they get lucky. And the more nervous they are, the less likely this is.
And there is some evidence to suggest that the smarter you are, the more you can be tripped up in a situation like an interview. Smart people in a nervous state can spin up thought loops very quickly. "Oh, no, am I going to be able to answer this or am I going to look stupid?!" - looping continually at high speed. Check out: Choke: What the Secrets of the Brain Reveal About Getting It Right When You Have To http://www.amazon.com/Choke-Secrets-Brain-Reveal-Getting/dp/1416596186
2
u/Icanflyplanes Oct 31 '13
Yep, over analyzing and overthinking is a trait in High Intelligence individuals, in the Right circumstance they Work like a Cray, but if you stress them, Well, they wont function properly.
TL;DR If you Download ASK and "MakeMyPcFaster" you Can make even a supercomputer slow
2
u/indyK1ng Oct 31 '13
Pretty sure how this is how I fucked up my Amazon interview. Got stuck in a loop of "I'm nervous, think of a solution, that's the last solution you thought of nimwit, he doesn't like this, I'm nervous, think of a solution ..."
4
u/gargantuan Oct 31 '13
Yeah I am like that, sadly. I would rather the ask for a code sample than put in a room and me solve small puzzles that quite often never ever get used in the workplace.
1
u/jk147 Oct 31 '13
A friend of mine was asked with that ridiculous 100 doors question. The guy probably just looked up tough interview questions online.
12
Oct 31 '13
I'm wondering if asking candidates to send in answers to a simple coding problem, then selecting them based on the quality of the solution and documentation would work better than the current process.
18
u/WhyIsTheNamesGone Oct 31 '13
That's brilliant, no travel needed, and if they cheat and crib a solution... so what? Doing that on the job is kosher anyway.
11
u/sordidarray Oct 31 '13
You forgot to mention the prologue: An hour or longer phone screen (usually multiple) where the interviewer links you to a collaborative editing website, asks you a puzzle question, and then puts you on speaker and themselves on mute. Then a short window at the end where you get to ask about the things that actually matter. And if you're lucky, you might be able to judge by their urgency to hang up at the end whether you can expect to be treated to the first-class service that you described above.
And also the epilogue: Almost everyone who gets successfully hired that way seems to think there's nothing wrong with the process, and will readily defend the practice.
9
u/Grundy23 Oct 31 '13
HR "flack" here. Unfortunately your story is very common. I can tell you though that there are many good, both large & smaller companies who are making huge improvements in their interviewing processes. My current company and my previous company both implemented behavioral interviewing processes, meaning all interviewers have been trained in how to properly interview candidates using questions based on past history, as well as greatly improve the candidte experience, and make informed decisions on who to hire. Both made the decision that once a candidate had been chosen to be brought in for interviews (post phone screens, post phone interviews and/or video interviews) they were to be treated as though we want them and really like them, and knowing that the candidate is also interviewing our company and our team.
We still have issues regarding the air travel piece, as it's difficult to get someone to this city on-time no matter how you work it. Scheduling travel in general for a candidate as well as trying to coordinate busy schedules on the company's side is a beast and there are always last minute changes and disruptions. But, once we decide to bring someone here whether they are local or not, we want to get as many interviews done in a day as possible and have it as pleasant an experience as possible. Our candidates are also our customers, or so we hope. We also always schedule a lunch interview or lunch break, and bio-breaks in-between.
Having said that, there are still hiring managers who feel as though part of the interviewing process should include travel delays and last minute adjustments, to see how the candidate handles this. Maybe this is how that manager was treated/tested or maybe they just like hazing, who knows. When this comes up we (HR flacks) stress to them that we have other screening, testing and assessments in place to make that determination and this new process actually works much better. Also, our candidates are kept informed, especially when the tough call to tell them that they have not been chosen has to be made.
I guess my point is that there are companies who are using good interviewing/hiring/onboarding practices, but unfortunately there is no easy ways for a candidate to know which ones are, and the negative stories like this will always show up more often.
28
u/WhisperSecurity Oct 31 '13
Based on something you said, I know who you work for.
I've interviewed with them, and so have several people who came through the same CS program with me.
Here's what you do right:
Candidates who are not getting an offer are informed quickly.
You feed candidates at midday unless they have some kind of food allergy, in which case they are on their own.
Here's what you do wrong:
Shockingly low offers. Maybe you expect that people are going to negotiate. I rejected you out of hand.
No feedback for rejected candidates. You've left many young software engineers unsure if they made technical mistakes, or just lack the social skills to make people like them.
Whiteboard coding instead of workstation coding.
Six to eight hours of interviews, instead of something more reasonable.
Interviews with people whose roles and prospective relationships are unclear.
Interview sessions of one hour, when asking complex whiteboard coding puzzles, AND asking background questions, AND doing general technical discussion, AND leaving time, theoretically, for the candidate to ask questions. I was constantly getting cut off.
No initial contact with HR. I was met by my first interview, who was an engineer. HR was never anything but a voice on the phone to me.
No closeout contact with HR. I was dumped in the lobby by an engineer who had no idea about the hiring process, and no ability to answer any of my questions about when I could expect to hear, or what the next step would be.
Overall, interviewing with you was, for me, a miserable experience followed by an insulting offer. For some of my friends, interviewing with you was a miserable experience followed by a confusing and unexplained rejection.
You may say that there are "companies who are using good interviewing/hiring/onboarding practices", but every company thinks this, and most of them are wrong. This includes you.
And here's why:
once we decide to bring someone here whether they are local or not, we want to get as many interviews done in a day as possible
Wrong mindset.
This right here is indicative of a bottom-line approach. "Oh, we went through the princely expense of flying this guy out economy class, and paying for one night in the cheapest hotel we can get away with. We want to make sure we get our money's worth."
Throughout interviews at your company, I heard lip service to the notion that everyone is a customer, and had people assure me that this wasn't just a slogan. But I'm old and wise enough to know that you don't listen to what people, you watch what they do.
And what you do tells me the real story.
You see, big tech companies pay tech talent well because they have to, but they treat tech talent horribly, because they come from one of two cultures, either "suit culture" or "nerd culture".
Suit culture regards nerds as a necessary evil to be treated only as well as one has to, and controlled as much as possible, and never, never allowed to realize their true market value, lest they start to demand ownership over the things they build.
Nerd culture treats nerds almost as badly, because nerds not only lack social skills (which could be rectified), nerds lack respect for the concept for social skills. They don't understand why it's important to treat people well and get along with them, or why it's important to ostracize people who behave in socially unacceptable ways. Even more importantly, nerds mistreat each other because they have no group loyalty. They denigrate and haze each other constantly, trying to prop up their own self-esteem (often wounded by the contempt society holds nerds in) by trying to prove that they are the smartest nerd in the room.
They do not understand that they are setting fire to their society in order to be king of the ashes. The esteem that they, as technologists, are held in, is much more dependent upon how much respect technologists are held in, not whether they are the best technologist in the room. This is why software engineers earn six-figure salaries and work in cubicles. The respect does not reflect the market rate, because we fight, and tear each other down, and haze each other with six-hour gang-bang interviews.
What physician would put up with that? What lawyer? What actuary? What postdoc applying for a tenured position? We are the profession of whom the most, the highest degree of technical competence is required. To be a software engineer is as demanding in terms of actual technical competence as to be a surgeon. Not a physician. A surgeon.
Yet we do this to each other, at the behest of outsiders.
Why? Because we refuse to pull together. We take each beating at the hands of our intellectual inferiors as a badge of honour, bragging that we "got a job offer from Google", "got invited for an in-person at Oracle" instead of refusing to sit for six hours of endurance test because no one should dare to treat software engineers that way.
We have to stop worrying about our individual bragging rights, and start standing up for each other.
1
u/Grundy23 Nov 01 '13
I'm pretty sure that wasn't my company. I don't work for a tech company. I found this link because of the BestOf. My company is rather large, and global, but not in the tech industry.
Also, based on your interview experience, that definitely wasn't our style, so if it was us I need to get some feedback to our team. Here someone from the HR team would have booked your travel, greeted you upon arrival, gone over the days agenda, led you through the day with breaks and lunch, and got you out the door.
I can see how your scenario might fit the mindset of a company who does not have the same processes that we do. And even though we are not a tech company, we ALWAYS do the techical screening prior to in-person interviews.
Wrong mindset. This right here is indicative of a bottom-line approach.
I could go into detail about how we use only the #1 & #4 rated hotels in our area, we reimburse for meals and car rentals, and the cost of the flight is not a huge factor, but honestly the overall expense of bringing in the out-of-town candidates is always scrutinized in the end. We don't set out to be cheap, but we do try to make sure that we are smart in who we bring in. If that means scheduling as many interviews as possible in a day so that we don't have to fly someone out multiple times then we do that. If we have to spread it out we do. And if we can do some over skype then we do. But honestly, most managers want to meet their top candidates in person. Many (not all) top candidates are working or have other conflicts, so scheduling multiple trips is not always feasible.
But I am curious as to what you think the right mindset might be? I have the ability to effect change in this way in my company so your feedback, and others, is valuable.
Thanks!
5
u/WhisperSecurity Nov 01 '13
I'm pretty sure that wasn't my company. I don't work for a tech company.
So, not Amazon, then? My mistake. You coincidentally echoed one of their internal slogans.
Wrong mindset. This right here is indicative of a bottom-line approach.
... We don't set out to be cheap, but we do try to make sure that we are smart in who we bring in. If that means scheduling as many interviews as possible in a day so that we don't have to fly someone out multiple times then we do that. If we have to spread it out we do. ...But honestly, most managers want to meet their top candidates in person. Many (not all) top candidates are working or have other conflicts, so scheduling multiple trips is not always feasible.
But I am curious as to what you think the right mindset might be?
Instead of saying "we want X, we're spending Y, how do we make that work", which is focused on the budget, ask a question focused on the person.
"We are creating a relationship with this person, how much do we want to invest in them?"
This implies the questions:
How much is our relationship with this person potentially worth to us?
What is the likelihood of realizing that worth?
How does the amount we invest affect the previous question?
How do other ways we treat this person affect the relationship?
A relationship with a software engineer, for a tech company, is a very, very valuable thing. It has to be, otherwise software engineer would not be such a high-paying profession. Moreover, a relationship with a software engineer has auxiliary benefits, the most important being access to other software engineers whom you would not otherwise have even known of.
So you are having a first date with an important resource. How do you want to proceed? A software engineer is someone who can make you money, just as a potential client is someone who can make you money. If you are taking a potential client to lunch, do you take them to the local greasy spoon or fast food joint? Do you pump them with questions, or subject them to a high-pressure sales pitch to "make sure you get your money's worth"? Do you insist on bringing along twelve people because they all want a look?
No.
The approach attitude of "getting a look at someone is a fixed expense, how can we maximize our return on it?" is silly, because it assumes that software engineers who we are trying to hire because they are clever, are not very clever at all, and won't see what you are doing.
I may not be the greatest software engineer in the universe at passing high-pressure mob-style tech interviews, so maybe I'm not the smartest guy out there, but I do have an IQ over 150, and I'm capable of reading a plane ticket. I know that I'm getting the real story about how well I can expect to be treated, the real story about how much I am valued, the real story about how effective the organization is, by figuring out how much that trip cost them, and what additional dollar amount it would have cost to make my trip comfortable and stress-free. I know what the additional charge for a first-class seat is, because the airline asks me, right there at the airport, if I would like to upgrade. I know how much it cost to have a car and driver meet me at the airport, and I can subtract and get the difference between that and the cost of a cheap rental car.
I know exactly what a company paid for the opportunity to talk to me in person. And I know how much more it would have cost to make my trip comfortable and less stressful, to not stick me in a veal-calf fattening pen, to let me worry about preparing instead of navigating a strange city, to let me check a damn bag without being charged extra.
And I know what percentage the second is of the first. It's typically around 20%.
So that's the experience I have. And to put it in perspective, something you may not have considered, is that all the while I am traveling, I am constantly being reminded that I am not considered worth that extra 35%.
When I arrive at the airport and check in, the automated system asks me if I want to upgrade to business or first class, and shows me that there are several such seats open. It asks me if I want to check a bag for $50. Please swipe credit card.
I go through security, walk to the terminal, start to wait to board the plane. I'm in boarding group 4, so I get to wait awhile. With me at the terminal are bunch of old white guys in suits, talking away on their phones, and I know who they are. Regional director of something or other. Project managers. Salesmen. They are not in boarding group 4. They are flying first class, and their luggage is checked. I make as much as these guys do, but no one would dream of sticking them in the rear of the plane.
I am in seat 37B, in the tail of aircraft where the seats are six across, right next to the screaming baby. (FAA regulations mandate at least one screaming baby on all flights over two hours). I am over six feet tall, so this is like being in a coffin, except in a sitting position.
When we arrive at the airport, there are some guys waiting with signs, and those signs have names on them. The suits find their respective sign-holders, the sign-holders pick up the suits' bags, and off they go. I shoulder my duffel bag and laptop bag, and go search for the rental car desks.
Collect rental car (economy class) from disinterested teenager, who asks if I want to "upgrade". Please swipe credit card here. No? Well, please swipe credit card here anyway. We need to be able to bill you for any overages, or if you don't fill it back up before bringing it back. Oh, did you want sat-nav? That's extra. Swipe credit card here.
Drive off, try to navigate through a strange city at 11pm local time, to a different strange city and find the address of the Discomfort Inn I'm booked at. Check in. Please swipe credit card here, because any changes you incur are your own responsibility, sir.
Try to check my email. There are no ethernet jacks, the wireless network has a paywall (please swipe credit card here), and my phone has no bars. Oh, well. Let's try and get some food and then sleep.
Room service stopped two hours ago, and anyway, they've never heard of celiac disease, and they don't know what "gluten-free" means (isn't it some kind of fad diet they have out in California because you're all just a bunch of new age hypochondriacs?). Not much else is open, either, and good luck finding something I can eat.
Go to bed hungry.
Discover that the A/C doesn't work right. Attempt to trick it by setting a glass of hot water on the thermostat part. Partially successful. Attempt to draw curtains against the thermonuclear powered halogen light that's right outside my window. Discover that the opaque curtains don't actually draw, and are purely decorative. Draw the gauze things as best I can, pull a pillow over my head, and try to sleep.
It's finally manage to sleep at 3am.
Wake up at 730, famished. There's a breakfast buffet downstairs, but not for people who can't eat gluten, there isn't. Gotta get to the company location by nine, gotta check out before I leave, because checkout time is 11 am. Shower, get dressed, go over the room carefully to make sure I've left nothing behind.
Check out. Shall we bill this to the credit card you swiped? What? $Company_name? Oh, yes, I guess they are paying for it. Have a nice day, sir.
Try to find company location in strange city. Park. Here's your ticket stub. Don't forget to validate, or we'll charge you for parking.
Show up in the lobby, and sit cooling my heels for 15-20 minutes after my appointment time, until the first engineer of the day can be bothered to come down and meet me.
So that's how I start your interview. I've had four hours of sleep, and nothing to eat in the past 24 hours. I've just been shuttled through a system that constantly reminded me of how little you think of me, by trying to upsell me all the comforts you wouldn't pay for. I'm exhausted, disoriented, stressed-out, famished, and my head hurts.
Now I get to take a Comp Sci exam.
Can you understand why, at this point, I might not like you very much? You've set me up to fail, but, hey, you saved six hundred dollars! Never mind that our prospective relationship should be worth much more than that to you, even if you don't offer me a job.
See, when I talked about the guys in suits, the guys whose actual salary market value is no greater than mine, having their comfort seen to, it told me what the real story is.
It told me that large companies, even tech companies, hate technologists and engineers. They pay us handsomely, but not because they think we're worth it. Instead, they do it because the market is forcing them to. They pay the regional manager of sales ~150K a year because they think he deserves every penny. They pay me ~150K a year because if they don't, someone else will.
It's a reminder to me that they don't think I deserve to be highly paid unless I wear a suit and have people reporting to me. Why? Because the people making these kinds of calls wear suits and have people reporting to them. And people like other people who are like them.
So, the question is, if I am a software engineer that the market values very highly, and I have taken the time to come visit you, do you want to make me feel like that? Angry and insulted? Or, if my self-esteem is more fragile, small and valueless and unimportant instead?
Sure, you loosen up the purse strings and take more time to talk to me IF you make an offer. But by that time, the initial impression is already formed. If you're only nice to me when you know I'm worth money to you, then you're like a dinner companion who is nice to me and rude to the waiter... obviously not a good guy.
Someone's character is revealed in how they treat people whom they do not need something from. What does YOUR company's behaviour say to me about its character?
3
2
u/Grundy23 Nov 03 '13
Thank you for taking the time to share this information. I don't work for Amazon and don't want to, especially after reading about your experience. I would like to share this with my team though, to show them an example of what a bad experience looks like on the candidate side as we continue to improve our interviewing and on-boarding processes.
Good luck in your search!
5
u/WhisperSecurity Nov 03 '13 edited Nov 05 '13
Thanks for the good wishes, but I turned out fine. I got a nice offer from a local small company in the financial services industry, and, so long as you are using this as training material, here's what that was like.
Headhunter agency tells me about company, ask if they may forward my resume. I consent.
Have a phone conversation with the CTO. After talking about the position, he asked to explain a little bit about my background, then asked a couple of screening questions about the fundamentals of C++, data structures, and Linux. Instead of asking gotcha questions about brainteasers and corner cases to see if I could get them at all, he asked questions about fundamentals to see if I could answer them easily, fluently and completely.
He was quite impressed with my answers, and told me on the spot that he wanted to do an in-person. We couldn't make our schedules work together that week, or the next, and, while I assured him that I would give everyone a fair chance to make an offer, he expressed concern about being edged out, and asked if I would be willing to meet with him that weekend, any time that worked for me.
Meet CTO in front of the building on Sunday afternoon. Talk a little bit, go into a conference room, a chance remark about plans from earlier that weekend leads to the discovery that we are both gourmands and food snobs. Spend the next 20 minutes talking about the proper way to make risotto.
When we get around to the tech interview, it's a mix of talking about my background, talking about the position, and technical questions. These start with background knowledge questions, more difficult this time, but still about fundamentals. Some discussion where I rant about my philosophy of software engineering.
When the whiteboarding/problem solving question comes, it's about solving an actual problem he encountered in his own work, not an obscure algorithm plucked from a Comp Sci textbook. I start with a some initial hesitation and headscratching, ask a clarifying question or two, then hit on what was the actual approach he used. I am busily improving that when he stops me... he's seen that I can do this, he's not going to wait for me to turn my pseudocode into C++.
We discuss salary numbers right there. He tells me he's not interested in dickering, and tells me what his budget for the position is. Says that the next step is that he wants one of his people to meet with me, because he always wants someone else to check his thinking.
Meet with one of his software engineers on Tuesday. Not so much an interview as just talking shop. They tell me they have one or two more people to meet with, but that I am far and away their strongest candidate thuis far.
Offer arrives two days later.
So what did he do right?
He treated me like a person he was meeting first, and a candidate second. We met as people, and then got down to business. This not only put me at ease and made me feel like a priority, it also helped him understand me so he knew how best to evaluate me
He evaluated me based on my ability to do what he needed done, not by giving me an impromptu IQ informally designed (and never validated) by someone with a degree in CS rather than psychology. Sure, IQ tests are good predictors of job performance. But you are not qualified to write one, and, no, asking someone how prisoners should communicate by flipping light switches, or how travelers stupid enough to bring only one flashlight should get across a bridge doesn't count.
He had me meet with one guy for three hours, not six guys for one hour each.
He had me meet with the person who had the authority to make a hiring decision (in this case him), not a bunch of pseudorandomly selected developers. Having at least one engineer interview a candidate is critical. Having five more engineers do so just duplicates effort, stresses him out, and increases the likelihood of false negatives.
He was transparent at all levels and stages. He told me when he was impressed. He would have told me right off if he hadn't been. He told me why he wanted to meet on Sunday. He told me what each stage would be like. He told me why he wanted me to meet with another guy on Tuesday. He told me why he asked each question he asked. He told me what his budget for the position was.
→ More replies (1)1
u/elahrai Oct 31 '13
Thank you for your efforts :)
Also, just to pick up on one note you made, I fully agree on the "interview candidates using questions based on past history" bit. You can get a pretty accurate sense of how much a particular candidate actually contributed towards each item on their resume simply by asking about that stuff.
If they have "Improved performance twofold on flagship application," and you ask "How?" you'd expect at least some detail regarding what the ill-performing aspect(s) of the application were and what they did to sharpen them up. If you get some short, abstract bullshit, complete with a blank look in response to your follow-up questions, then the item's either bullshit or the candidate was only tangentially involved (which many bad candidates still feel is enough to include it on a resume). Even if the dude forgets a lot of it (which they shouldn't - you should study your own resume before an interview, gotta remember that shit!), you can still usually get that "feel" one way or the other.
Having the candidate walk you through the thought, design, implementation, and/or debugging processes they used on a few of the highlights of their resume, imo, tells you a lot more about them than their answers to "how do I re-arrange the characters of this string."
8
u/Dlotan Oct 31 '13
I just had this two days ago. I´m in university and this was for an internship.
I have to say that im studying currently and this was the first interview in my life (for an internship) . The HR guy was like super friendly all the time and i thought I`m doing pretty well. Solving every problem on the spot. Most of the time not the best solution but all the time a solution which just worked. But in the end I didnt get an offer which was okay for me. But the fact that got me pretty disappointed was that its "against company regulations" that they share feedback with me. After that they like kicked me out of the building and didnt even let me say bye to the guys who where there also for an interview and stayed with me all the time.
I mean what the fuck???? At first I thought that i wasted just 2 days of my life but now I think it was my lack of code optimisation (performance) which took them to the point of not making me an offer.
But I really dont know for sure whats wrong maybe it was just me and I got a bad attitude??? I dont know. I got a telephone interview with a company of the big ones from california yesterday and again in the next 3 weeks and I have like 0 confidence. The interview yesterday was pretty good but every question I thought that its not a good answer. I
m motivated to improve and Im studying a lot these days but it`s just so hard if you dont know what to study...4
u/whymustthisbe Oct 31 '13
Suggestion; if you know your solution is not optimal, mention that and speak to how it could be improved.
3
12
u/vividboarder Oct 31 '13
Well my interview at my current company was nothing like that. If that's really how most go, then I'll consider myself lucky.
I also do interviews. Right now about 4 a week. (Know any SFDC developers? Heh)
I keep all this in mind with every one of my interviews. I try to put myself into their position. I know what it's like to be on the other end of the line. I've been there myself.
Nervous. Anxious. Panicked.
As a result I care more about their process. Yes, getting the "best answer" is good. What I really want to see is how you disect a problem. What steps do you take to derrive your answer. I can get most of this without making the candidate code, but I still have a code test.
On my code test I want to know how careful you are. Do you re-read what you write? When you make mistakes, do you catch them when you re-read your code? Do you properly indent your code or make sloppy errors? Since I'll potentially be reviewing a lot of your code: Is it code (correct or not) that I can read?
So yea, try to come up with the best answer, but beyond anything else, make sure you try and communicate what you're doing.
My worst interviews ever are when I give the candidate an intentionally vague problem and they just say "OK" and then write the whole thing without another word. I give you a vague problem because real world problems are rarely anything but vague. I want to see you ask questions. I want to see how you construct a problem before you solve it.
But you are right though. There is always a dice roll. You can never know for sure if the guy just had a bad day, but you shouldn't be setting them up for failure and ensuring it.
6
u/BezierPatch Oct 31 '13
Do you properly indent your code or make sloppy errors?
Well, if you give them notepad or some unfamiliar IDE you kinda have to expect a ton of errors.
I'm completely out of the habit of writing good code in plaintext since using Visual Studio for a while.
→ More replies (2)1
u/Stromovik Oct 31 '13
Writing code on paper is the worst , due to a medical condition my handwriting is almost unreadable to most people.
2
u/gargantuan Oct 31 '13
I also do interviews and am trying to always hunt for better type of problems. I do not like puzzles (like manhole cover one or you got thrown in a blender) so we do stuff like "traverse this tree".
What kind of questions to you ask (you can pm me and if you don't feel like divulging it to the whole world).
3
u/whymustthisbe Oct 31 '13
My favorite interview was when my soon to be boss pulled out the ACM programming contest problem set and he picked 2 and I spoke/sketched out a solution from my existing knowledge that could solve the problem.
2
u/YanYanFromHR Oct 31 '13
as an interviewee, one I liked was kind of like the NASA Armageddon test. For a web developer job they'd pull up one of their previously broken websites and give you 10 minutes alone to write down all the errors and sloppy coding you could.
Problem was though, you weren't sure if some things were wrong or designed that way. So I'd usually add them and say "Could be wrong coding, or just poor graphic design."
6
6
u/Kelvrin Oct 31 '13
This except x1000 for any government position.
The first time I intervied for a gov position, all the instruction I was given was "This is your plane ticket, take the airport shuttle from the airport, and this is the address of your hotel. Someone will meet you in the lobby in the morning."
So cut to flight landing, and using the signs to find out that there is an "airport shuttle" and an "airporter shuttle", one runs North and the other runs South, the direction I actually need to go. Spoke the with airporter rep for a few minutes to determine this, and hiked across the airport to get to the actual pick up location.
Get on the airporter, which is a small bus that runs between two points, dropping people off on the way. At one point, we just pulled over to the side of the highway for a bit because "I'm early on my route. Have to keep the same timing." So we sat on the road for 15 min just waiting.
As we trundle along, I expect that the shuttle will pull up and drop me off at my hotel, as most of the stops so far were near hotels. As the list of stops finally reaches its end, 2 hours after I got on, I get escorted off the shuttle with my bag at a gas station at a crossroads in the middle of the woods. In a city I don't know.
Had to use a cab to get the rest of the way to my hotel.
The sheer ridiculousness of the whole thing was the only reason I wasn't stressed out beyond belief the next day. Which is good, because the interviews ran so long that I missed my flight out. Kudos to whoever made the itinerary for that day.
6
u/nahvkolaj Oct 31 '13
This is exactly how my interviews went at medical imaging companies, except I'm not a computer scientist and I was interviewing for engineering positions. One time at a company in the Santa Barbara area, I just had a bad day, forgot all my thermo and even some of my optics knowledge. Never heard back from them and it was a long drive back home. But the atmosphere of the place was uptight and did not seem very flexible.
Compare that to my current job, which was barely an interview. I was on station all day going around with my hiring manager seeing all the "cool" things that happen here, and it was an opportunity for me to ask a lot of questions. Then we went down into a lab, and he had me play with an IR camera where he got an idea of what my practical knowledge of optics was like. At the end of the day he had a good idea of what I was interested in and about what my knowledge level was. That was definitely my best interview experience and I think it was a good tactic.
6
u/wild_bill70 Oct 31 '13 edited Oct 31 '13
My counter offer here is the following experience from a small division of a large company:
Fly in the morning of the interview
Picked up at the airport by the CTO in his Mercedes
Taken to the office for a short interview with the CTO
Interview with the whole team I would be managing (it was my first s/w management position with no prior experience, so that part was a little weird
Taken to lunch with the rest of the management team
Made an offer on the spot that was better than I ever imagined
CTO took me to get drug test (which is another fun story)
Returned to airport to fly home same day
I accepted the offer pretty much as it was a few days later.
-- Edit, clarify that my experience was from a small group within a larger company
4
u/WhisperSecurity Oct 31 '13
And yet, I see elsewhere that you were treated as I described by Amazon and Google.
Let me guess: at those companies, you were applying for an engineering position, not a management position.
This disrespect is not mandatory, not an unavoidable artifact of the evaluation process. It's something they can get away with because engineers have failed to demand, and enforce, a degree of respect commensurate with our market value.
3
u/wild_bill70 Oct 31 '13
I suppose I should have said the counter offer was from a small division of a mostly non-technical company. My experience from larger companies has been as noted.
4
u/once-more Oct 31 '13
This sounds strangely familiar. And partly explains why hiring seems surprisingly random.
1
u/YanYanFromHR Oct 31 '13
Now we just need to solve the randomization algorithm used for hiring...
1
u/once-more Oct 31 '13
Indeed. Basically, the more you interview, the more offers you will get, generally. (Assuming basic hygiene, etc.)
The hard part, in my experience, is trying to predict which of these offers leads to a pleasant (or at least tolerable) outcome. I'm all ears...
2
u/gt_9000 Oct 31 '13
Also, the hardest to please interviewer must be the last interviewer of the day.
2
Oct 31 '13
This is very true. And what I hate most is the impossibly hard tech interviews, asking you about obscure C++ keywords that you might use once in your career if you are lucky. Is that really so important?
I get tested on the 1% edge cases instead of the 99% use cases, ALL THE TIME.
1
u/Arguss Oct 31 '13
I'm about to do an interview which I suspect will be very much like this. Much of my itinerary is pretty much word-for-word what you posted. It was pretty amazing reading through your post and feeling that you were psychic.
1
u/cathline Oct 31 '13
Or, they wait 3 months (after they have hired someone else who did a spectacular crash and burn) to talk to the employee who referred you for the position - and offer you the job after you have already accepted a long term contract making about the same but with no benefits.
And that employee has already told you about the spectacular crash and burn, which you could have warned them about, because you had to fire that guy at a previous position.
1
u/pinkwhifflebat Oct 31 '13
Thanks for the terrific answer. I had no idea it was like that.
Do you think this might be relevant? http://michaelochurch.wordpress.com/2012/11/18/programmers-dont-need-a-union-we-need-a-profession/
1
1
u/UnwarrantedPotatoes Nov 01 '13
This sounds pretty familiar, except I got a car with SatNav, and they put me up in a decent hotel.
Otherwise… very damn familiar.
1
Oct 31 '13
Evaluating developer candidates is a bit like managing software projects... there's a lot of theories floating around, but none of us really knows how to do it.
They could start by doing the opposite of all those nonsense things you itemized.
A lot of software companies treat people real badly. It's like they forget they're dealing with human beings, or that the companies are run by sociopaths.
-2
u/andd81 Oct 31 '13
But still it's a nice way to travel (mostly) at the expense of your would(not)be employer, and generally a fun experience. You're not losing anything by not getting an offer, anyway.
5
u/TheLantean Oct 31 '13
You're losing a night's sleep, several days of your life that could be spent on freelance projects or on a real vacation, and get to stress out being lost 50% of the time in an unfamiliar city. Sounds just peachy.
→ More replies (24)-2
u/SouthernMan85 Oct 31 '13
Ok, coming from a guy who actually does a lot of recruiting for a large company who hires programmers let me drop some knowledge. First of all, most of your interviewers could potentially be your co-workers or project managers. Typically we tap people who have been working professionally for 4-5 years to do the interviews and yes you are right, most of them would rather not be doing it. The types of interviews vary based on the company but with our company you get one technical and two personality interviews. Funny enough the personality interviews have the largest effect on who we hire. Technical skill can be taught and can be learned once someone comes in the door, their personality however is a different story. Personality can not be taught, it is not something you can pick up on the job. In a team environment it does not matter how smart you are if you can not work with others. I will take a person with a good personality and C- programming skills over a A+ programmer with a shitty personality any day of the week. So just based on your post and the tone of the post and the words you used, I assume this is your problem OP. If you walk into the interview process with a chip on your shoulder I wouldn't be surprised they turned you down.
4
u/WhisperSecurity Oct 31 '13
Are you a software engineer?
If the answer is "no", then you are not qualified to know whether personality, technical skill, or intelligence is more important for succeeding as a software engineer. You are also not qualified to judge what kind of personality traits are important for a software engineer to have.
If you do not have a background as a software engineer, you do not have any clear notion of what makes large/significant software projects succeed or fail, and could probably be replaced on any hiring panel with a potted plant, with no discernible effect on the quality of its hiring decisions.
And if I walk into an interview and realize that I am being evaluated by someone without the professional qualifications to understand what I do, I typically reject whatever offer they eventually make.
4
u/SouthernMan85 Oct 31 '13
Yes I am a software engineer, so yes I am qualified to interview and to judge candidates. And like I said, a person with a good personality will get hired over those with bad personalities. Programming skill can be taught on the job or with some training, personality can not be taught.
2
u/WhisperSecurity Oct 31 '13
Programming skill can be taught on the job or with some training, personality can not be taught.
Oh, but it can.
Not taught per se, but it's important to understand that what we mean when we say "personality" is really behaviour. And that behaviour is dependent upon local (company) culture, and on context.
Certainly some aspects of personality are important, but I'm not entirely sanguine about getting a good read on those based on the situation candidates are being put in. Under that kind of stress, in an unfamiliar environment, sleep-deprived and disoriented, friendly, outgoing people can become shoe-staring mumblers; quiet, reserved people can become manic; careful, cautious people can become eagerly confident in off-the-cuff wrong answers.
The problem isn't criteria as such. It's a sort of Heisenberg uncertainty principle for people. The more precisely you try to observe something, the more you change what you are observing by the act of observing it... and hence, the less valuable your observation becomes.
1
u/SouthernMan85 Oct 31 '13
Excellent point, I have to admit. Well I'm sorry you have had such bad experiences with interviewing. With the company I work with you would have to travel but all those travel arrangements are left to you(at least for us). So the corporate people are going to try and fly you last minute, have you check out early, get a rental car etc.. to save them money. But with our company you can choose an earlier flight, you can expense the cab fare etc. to get to the place and you can even extend your stay. My best advice is to leave your feelings at the door to the interview, if you don't know an answer or can't remember something say so and most importantly just talk like you normally would. Don't try to fancy yourself up for an interview, a lot of people can see right through that, be real.
26
u/JustinKSU Oct 30 '13
As someone who has done many interviews of both experienced and new developers I can confirm this. It is way more important how the developer approaches the problem, than getting the solution perfectly right.
4
1
u/colly_wolly Oct 31 '13
So what if they did come out with a correct solution,quickly and without explaining anything?
1
u/JustinKSU Oct 31 '13
If it were that quick, I would probably ask them a different question. Part of the purpose of an interview is to see how someone reacts to a problem that is unknown to them in a stressful situation.
9
u/thegrubclub Oct 30 '13
I don't understand how this is a riddle question at all. This is a very reasonable algorithmic problem with a clearly defined domain. It's possible that there were other red flags, but certainly this is solvable, not some "why are manhole covers round" bullshit.
9
u/alienangel2 Oct 31 '13
Yeah seeing people call this a riddle or a "mensa problem" is I guess making me understand why some people do so badly on technical interviews. This isn't a trick question of any sort, it's a straight-forward "think about the problem, figure out how you can solve it, examine the runtime of that solution, identify why it has that runtime, think of a better way to do it" problem. Do all that while thinking aloud, and your interviewer will be happy. Show us you can think analytically and you get the job.
All my teammates would spend a happy hour poking around this problem seeing how many ways they can think of solving it and what the trade-offs are.
1
u/colly_wolly Oct 31 '13
"All my teammates would spend a happy hour poking around this problem"
A lot of interviews only last an hour. As such you would likely be given maybe 15 minutes, under pressure to solve this.
2
u/alienangel2 Oct 31 '13
I'm aware of that, see my other comments in the thread about it. It's simple enough that you should be able to come up with some options within a few minutes, and the interviewer is there to guide from there. We would allocate around 40 minutes to explore this kind of question.
The comment about my teammates was to say how long they could be entertained with examining the problem and evaluating different solutions, not how long it would take to come up any solution.
1
u/colly_wolly Oct 31 '13
I think the point is, that if you came up with a problem with that at work, you would not be expected to come up with a working solution first time in less than ten minutes.
I personally would have a google around, see if someone has done something similar. If not, try and come up with an algorithm that works. Banging out the first code that came ion to my head as a possible solution, it will be down to luck whether it works or not.
8
u/drb226 Oct 30 '13
+1 this so much. A good interviewer won't care that you cannot instantly conjure up the correct solution, and it's not their job to guide you and give you hints so that you can arrive at the correct solution. Instead, the interviewer's job is to assess the way you think and solve problems.
0
Oct 30 '13
[deleted]
1
u/drb226 Oct 31 '13
i'd rather get a definite answer of "use this library like this" then a halfway/half-right dissertation
Given the context, which is a hands-on coding interview, I don't see how what you said here is relevant, and consequently, I don't think I get what you are trying to say.
1
u/nomeme Oct 31 '13
You are selecting for one of those annoying developers who re-invents everything.
The right dev would at least say "i'd see if there were any existing solutions first" and that is part of the "way they think and solve problems".
3
u/prolog Oct 31 '13
A riddle is something like "why is six afraid of seven". This is not a riddle; it's a straight forward algorithms question.
1
u/norkakn Oct 31 '13
Yes?
It would be a riddle if there were some trick that he'd have to get to figure it out. Riddles tend to be all or nothing.
Algorithm questions can certainly also be riddles, but this wasn't one of those situations.
0
Oct 30 '13
[deleted]
11
u/Unmitigated_Smut Oct 30 '13
If I'm going to ask someone to solve a problem in 30 minutes, it should be a problem that I solved myself in as much time. I've heard the same excuses over & over for toying with candidates and trying to make them panic, but it's really all about the power trip and not much else.
9
u/Crazy__Eddie Oct 30 '13
Not only that, it's really silly to expect everyone to just be able to explain their thinking process. I actually had an interviewer ask me to explain it out loud. I mean come on, when I'm thinking about a programming problem I'm often not even thinking in human language. Having to filter everything through the language and speech centers of my brain just totally fucks everything. It's like trying to think out the solution to a perfect form of modern economics where nobody starves while someone's sitting next to you randomly firing a 45.
On the other hand, I blew away the last group by realizing that processing a string backward would get me the solution to the expected problem in one line of code. They did ask me how I figured that out, but I of course didn't know...my brain just put 2 and 2 together. Luckily that wasn't the important thing.
Personally, I have found best results nailing an interview by just chatting with people. You can pretty much flunk the tech if you can get the guy to smile. It's the boobs that call you and read from a script that end up missing the opportunity to hire me. Engage, engage, engage.
5
u/nomeme Oct 31 '13
I actually had an interviewer ask me to explain it out loud.
Shocking! Must be one of those ultra rare jobs where you have to communicate with other humans ;)
0
u/Crazy__Eddie Oct 31 '13
That's a pretty stupid remark. You can communicate with other humans just fine without having to explain your entire thinking process in implementing simple algorithms.
1
u/gargantuan Oct 31 '13
So to turn it on its head, what would be a good question to ask you? Or maybe another way of putting it, let's say you are interviewing what would you ask to pick one candidate out of maybe 20?
63
u/RevBingo Oct 30 '13
I don't know why Justin told me "this should work," when my solution in fact didn't
Because maybe, y'know, Justin is a regular guy working for a regular company, who, just like you, saw your solution and thought it reasonable. He is not infallible.
Unlike the Pope - he'd spot the bug immediately. Talk about a rock-star coder.
34
u/ohwaitderp Oct 30 '13
Um, actually it's kind of a dick move - this isn't a random programming problem, Justin knew it well in advance and probably interviewed a bunch of people in his tenure there. He got to see a bunch of solutions and should have known this one was not right.
Given the assumption he knew it wasn't 100% correct, it's a total dick move. What if the interviewee just needed one more nudge that it wasn't right? or a hint for a test case that failed? he may be a very good programmer, critical thinker, problem solver, and be a great addition to Twitter's team but now Justin kept him from getting the job there (potentially). We can't know 100% why they didn't hire him, might not have anything to do with this solution, or it might have something to do with it, or it might be the whole reason.
We also can't know if justin actually realized the solution was incorrect, but it's not ok regardless. If he knew it wasn't right, he's kind of being a dickhead. If he didn't know, then he doesn't understand the problem well enough to be interviewing potential new hires using it.
18
u/628318 Oct 30 '13 edited Oct 30 '13
I also thought that was strange. When I hear something like "Yeah, that looks right to me" from an interviewer I take that as interviewese for "Ding ding ding! Correct! Let's move on." and I've never gone wrong with that assumption. It seems like if they know a solution is wrong, they at least shouldn't say they think it's right. I suppose it's reasonable not to give any hint that it isn't right, but why say that it is?
9
u/ohwaitderp Oct 30 '13
Bingo - I assume the interviewer is making a good-faith effort to understand how I solve a problem - how can I solve it effectively if they lie about my solution? I'm happy to keep iterating and refining my ideas to get a correct solution.
3
u/frtox Oct 31 '13
I do this. it's always when I am running out of time and need to move past the problem to talk to the candidate about other things. I don't always say this is right lets move on, but I usually don't say this is wrong lets move on. I leave it vague most of the time. does this make me a dick interviewer?
my reasoning is I already have a picture of how you problem solve and your skill set. you don't need to get the problem right for me to want to hire you, just the other parts of the interview are very important. in this situation in the past I've let people work down to the wire to finish. it doesn't usually change my perspective of them technically, actually it prevents me from learning more from them or them learning more about the company.
1
u/gargantuan Oct 31 '13
That was my thinking as well. In 45 or so minutes, I want to explore as much as possible what they know and don't, their problems solving skills, attitude, quite a few things. That's why one single problem is not the best approach.
However in this case (and we only have one side of the story), it did seem like the guy was thinking out-loud, was showing he can solve a problem, there was nothing else left to ask, and instead of giving them hint to help them, he said "yeah that's right" and it confused the guy. I don't know, the ability to see it they can quickly pick up and find the bug or fix the solution is important.
Maybe he just didn't like the guys accent or personality and technical results were kind of fudged in the end to avoid giving them good marks. So I would say he decided he doesn't want to recommend him for hiring at sometime before and just decided to mess with him. But that is also a dick move.
10
u/NYKevin Oct 30 '13
From the earlier scheduling snafu, it's entirely possible Justin didn't know it well in advance, and was just pulled onto interviewer duty because they needed an interview Right Now.
9
u/pigeon768 Oct 30 '13
I've been That Guy. Sitting in my cube minding my own business when suddenly two sets of fingers, a combover, two eyeballs and a nose bridge pop out over the top of my cube and I hear, "pigeon768! We need you in conference room 42 to do an interview. He'll be there in 15 minutes. I'll email you his resume."
"..........okay.." ಠ_ಠ
12
u/onezerozeroone Oct 30 '13 edited Oct 30 '13
Chances are Justin's manager or teammate asked him last minute to run an interview with an intern candidate. Justin has been working 50-60 hour weeks and has a big project due in a couple days. His colleague said "give him the water question" and handed him a stack of paperwork to sort through. Justin's last line of blow or adderall were wearing off by now, and Twitter's IPO is coming up...Justin doesn't particularly give 2 shits about whether he's giving a random intern a fair shake relative to the 500 other applicants...he's going to be a millionaire soon.
Chances are he didn't get the job because he was assessed as a non-culture-fit, meaning he wasn't cool enough and they didn't think he'd be able to keep up with the keg stands on Friday. At some point in the process they may have asked him if he likes node.js...when he didn't start masturbating at the very mention of it, he was assessed as a no-hire.
-4
u/ohwaitderp Oct 30 '13
Fantastic speculation on an employee you don't know, and you're obviously completely unbiased.
0
2
u/alextk Oct 30 '13
Given the assumption he knew it wasn't 100% correct, it's a total dick move
Maybe he didn't know. It's a pretty complex interview question and maybe it's the first time he uses it. In which case, he still gave the wrong answer and he should have shown some humility and answer the question "Does this work?" with something along the lines "Well, let's find out!".
1
u/lalaland4711 Oct 31 '13
What if they ran out of time?
Should they go "Nope, 30 minutes in you got to something that only works for a subset. I'm marking you a fail on this one. Gotta go, next guy is here."?
→ More replies (8)1
u/RevBingo Oct 30 '13
1
u/ohwaitderp Oct 30 '13
My point was regardless of why, it's a failure on the interviewer's part, not the interviewee's (necessarily)
1
u/PopeJohnPaulII Oct 31 '13
I did actually get the 'right' solution when I read the question.
But of course as others have mentioned his coding ability probably wasn't what they were looking for here. They were looking at his thought process and to see if he would cover all test cases.
Also, I'm only an OK programmer at best.
10
Oct 30 '13
[removed] — view removed comment
0
u/stgeorge78 Oct 30 '13
In Twitter's case, they probably have 4 or 5 infallible genius algorithm-memorizing savants to pick from already, so why bother with a "dummy". I have a feeling they already wrote this guy off and were hoping he'd get the hint when they weren't excited enough to call him at 5:30.
Hip companies like Twitter essentially are snobbish hot girls.
5
u/adrianmonk Oct 31 '13 edited Oct 31 '13
Nevertheless, not taking the "hint" is the right decision I think:
Calling after waiting a reasonable time shows that you are interested and you are capable of following up when things don't quite go
avoidingaccording to scheduleIt's entirely possible, even likely, the scheduling
mixmixup is due to a single developer who got stuck in a meetingIf indeed they are the kind of company that just stops calling, you needn't worry about their reaction when you fail to take the hint. That's just sloppy and disorganized, and it's a good sign you don't want to work there.
2
u/stgeorge78 Oct 31 '13
If a company shows no interest in me or gives enough respect to honor their commitments, then I have no interest in working for them since it's just an indicator that they don't and won't give a shit about you.
Trust me, they would have bent over backwards to make that call if he was someone they really wanted.
16
u/Richandler Oct 30 '13
Unrelated and hateful: You failed your Twitter interview because you don't let me highlight the text while reading the page. Why over-engineer?
3
u/grimeMuted Oct 30 '13
Yeah that page did something interesting things to my browser... didn't erase my middle-mouse scroll click thing and didn't let me click the gist link (had to browse the source and click from there).
8
u/austinpsycho Oct 30 '13
I wonder if it would be easier just to move left to right and subtract the difference if the right maximum is lower. Also, does this work with multiple pools?
1
u/oslash Oct 30 '13
move left to right and subtract the difference if the right maximum is lower
This doesn't work because you don't know what that difference is unless you do extra work. (E.g. recount in an extra sub-pass for every pool you identified, or make an array that keeps counts for every possible height the right wall might turn out to be once you find it.) Since the algorithm in the gist doesn't need any of that, it's actually simpler in the end, and it does minimal work.
does this work with multiple pools?
Yes. When you reach a gap between pools upon advancing a pointer, the maximum height stored for that side will become equal to the height of that wall in that column. Therefore, when you advance that pointer again, there is zero difference between these values and zero volume will be added. Once you reach a lower wall, a new pool starts and more volume accumulates.
The clever part is that because you never advance the pointer with the greater maximum height, the pointers are guaranteed to converge on the/a highest point. So even though you don't know yet how high exactly that will be, you can always advance through a pool from one of the pointers and add up the volume, knowing none of that water can drain out on the other side of that pool. (Because the/a highest point is guaranteed to be at or beyond the other side.)
In case this explanation wasn't any clearer than that in the article, just draw yourself an example with multiple pools and manually go through the code in the gist, updating the variables as you go. You'll quickly see how it has to add up correctly for every possible case.
0
Oct 30 '13
Pretty much... here is a solution in JavaScript:
function solvePuddles(hills) { var peak = 0, vol = 0, volumes = [], h, i; for(i = 0; i < hills.length; i++) { h = hills[i]; if(peak <= h) { peak = h; if(vol) { volumes.push(vol); vol = 0; } } else { vol += peak - h; } } return volumes; }With a fiddle to play with: http://jsfiddle.net/w6e2b/
Just move left to right, watching for the height to be equal to or greater than the previous peak. Then record the accumulated volume and reset. It's pretty simple actually. And yes, it does work with multiple pools
7
Oct 30 '13
failed when right side peak is less than left side peak as it assumes left side is always higher
[2, 6, 1, 2, 3, 4, 4, 5, 4] = input1[]
[2, 5, 1, 3, 1, 2, 1, 7, 7, 6] = input2[17]
[1, 2, 1, 1, 1, 1, 2, 1, 1, 2] = input3[4,2]
2
Oct 30 '13
Ooo! Good catch!
Here's my (rather hackish) updated version:
var solvePuddles = function(hills, isReverse) { var peak = 0, vol = 0, volumes = [], h, i; for (i = 0; i < hills.length; i++) { h = hills[i]; if (peak <= h) { peak = h; if (vol) { volumes.push(vol); vol = 0; } } else { vol += peak - h; } } if(vol > 0 && !isReverse) { var revHills = hills.reverse(); volumes.push(solvePuddles(revHills, true)[0]); } return volumes; }Basically if I see an "overflow" at the end, I just reverse it and go again, just taking the first puddle found and appending it to the result.
... if that makes sense.
2
Oct 30 '13 edited Oct 30 '13
I tried it a little different. Basically I just made a separate function to find the next peak, which will either be equal or greater, or else the next largest peak in the array. If I take the smaller of the current index and the one returned, I can use that as the "true" peak of the puddle.
Also, if the next peak is less than the value in the index before it, that means it's not a true pit (downward slope), and I'm at the end of the array.
function findVol(arr){ total = []; for(i=0;i<arr.length-1;i++){ if(arr[i]>arr[i+1]){ nb = nextBiggest(arr,i) peak = arr[i]<arr[nb]?i:nb if(arr[nb]>arr[nb-1]){ total.push(0) for(i;i<nb-1;i++){ total[total.length-1]+=arr[peak] - arr[i+1] } } } } return total; } function nextBiggest(arr,i){ next = i+1; for(j=i+2;j<arr.length;j++){ if(arr[j]>=arr[i]) return j; if(arr[j]> arr[next]) next = j; } return next; }Borrowed your testing inputs there http://jsfiddle.net/7EvhA/
0
u/Tekmo Oct 30 '13
Maybe it would be easier to first compute the total water for a given height assuming that no water flowed out the sides, and then subtract the side pockets that don't form a proper well.
0
u/BitMastro Oct 30 '13 edited Oct 30 '13
Almost: scan from left to right, keeping track of 2 maximums and 2 variables for current and old pool, if the value is lower or equal to the max, add the difference between max and the value to the current pool, otherwise move current values to the old values and set current max to the current height and zero the current pool. When you reach the end, the old pool variable carries the correct value.
Single scan, works with multiple pools and also no pools at all.
ninja edit: when swapping the current pool to the old pool you have to add the value of the old pool
6
u/oslash Oct 30 '13
If I understand your idea correctly, it won't work: You either finish a pool by finding a new maximum, in which case you know that pool is done and can transfer its volume to the "old pool" accumulator, or by reaching the end of the array, in which case you discard the "current pool" volume, assuming it will all drain out the right side. (Is that it?) However, that assumption can be wrong — the current pool you've been accumulating might not be watertight as a whole, but still have pockets that do hold water. Which you haven't been keeping track of.
→ More replies (2)
8
u/once-more Oct 31 '13
Having recently ridden this ride, the key is that there is huge variance in the process. If you interview with ten of these companies, you'll almost certainly get three or four offers. Do it again and you'll get another set, though not from the same companies. Same if you're Einstein. Or Fiorina. So don't sweat it. And don't read malice into it, because it's just mindless randomness.
26
u/Megatron_McLargeHuge Oct 30 '13
The problem is easy. The hard part is fitting the answer in 140 characters:
Think about horizontal bars. Keep track of the last index of each depth. When you get a depth shallower than the previous, sum the bars.
7
u/throwawaylms Oct 31 '13
int h(int[]g){int c,z,a=0,b=0,y=g.length-1,x=0,v=0; while(a<=y){ c=g[a];z=g[y]; if(c>b)b=c; if(z>x)x=z; if(b<x){v+=b-c;a++;}else{v+=x-z;y--;}} return v;}I give up, 147 without the whitespace, 123 without the function wrapper.
4
32
u/soviyet Oct 30 '13
Good thing they didn't hire him. If it ever rained near some boxes somewhere, they'd never be able to decide how much water would accumulate in one pass. Twitter stock would plummet!
Man, I'm so glad I never have to do these interviews.
15
u/intellimouse Oct 31 '13
I'm not sure why people are treating the water filling question like some silly riddle the interviewer asked. It's not a riddle, and it's not supposed to be something Twitter literally does, it's an algorithm design question. The answer arrived at doesn't matter all that much, what the interviewer is looking for is insight into how the candidate approaches problem-solving and algorithm development. And if he comes up with something, how he goes about analyzing and verifying it. We don't really care if he can come up with the O(n) solution for it immediately (although it certainly helps), we care whether he can see problems that might be there in the solution he does develop, and whether he can improve upon it.
If you think you will never have to develop even a slightly unusual algorithm while on the job and that this makes thinking of algorithms not worth your time, we probably don't really want to hire you.
3
u/S2Deejay Oct 31 '13
I don't get it either. I'm looking to hire a programmer, so I'm going to ask them to program during an interview - the horror! It's a very realistic problem to solve during an interview. It shouldn't be hard to write a program to solve that problem in under an hour.
-4
u/soviyet Oct 31 '13
That's cool, because I'm reasonably sure I never want to work for you. But,
If you think you will never have to develop even a slightly unusual algorithm while on the job and that this makes thinking of algorithms not worth your time,
You are missing my point, and I assume the point of every single coder that loathes these kinds of questions (which, I dare say, is most of them). Of course we have to come up with (sometimes unusual) algorithms on the job. In my job, that's almost a daily occurrence.
What we don't have to do is come up with them on the spot, under pressure, completely without context or expectation, without access to the Internet, while some half interested kid nods and withholds interesting or important feedback. Nothing about these interviews reflects a single day on the job, at Twitter or anywhere else short of some oddball puzzle factory.
Unless the average day on the job at Twitter involves people springing into your office and asking you to estimate the weight of a battleship full of jellybeans or whatever. In which case, yeah, I really don't want to work for you.
Read my response to the other poster here and see if my suggestion doesn't make a hell of a lot more sense than this. I mean its up to you how you do your hiring, but I think it could be done much, much more effectively than this.
5
u/intellimouse Oct 31 '13 edited Oct 31 '13
What we don't have to do is come up with them on the spot, under pressure, completely without context or expectation, without access to the Internet, while some half interested kid nods and withholds interesting or important feedback.
I suppose our point of view on this is that most of that isn't the case during the interview:
the pressure of an on-site interview isn't all that high (you will certainly occasionally be under much greater pressure on the job) - while for the most part it's a 9 to 5 write-enterprise-software job, you will still occasionally have Very Important People waiting for you to say something while your world burn$ around you.
the point of abstract questions like this is that they are context free. So long as you understand the question (and you're free to ask for as much clarification as you want if you don't) there isn't really any context anyone needs to solve it. More on this later to reply to your other comment.
You don't have access to the internet, but what internet resources do you think someone should need to tackle a problem like this? We aren't going to penalize you for not remembering the exact interfaces for a standard library or making syntax errors in your solution. We'll encourage you to make assumptions, just tell us what they are. We obviously wouldn't get any value out of your asking StackOverflow to solve it for you, and the question isn't complicated enough for you to need to read a SIGGRAPH or ACM paper to get ideas. But the interviewer is there for you to bounce ideas off, and to give you guidance - what questions you ask him is an important part of the interview.
the interviewer shouldn't be half-interested, or witholding important feedback. At least at Amazon we do take interviewing pretty seriously. If you're going down a dead end, we'll let you explore for a while to see if you spot it, but we will reel you back before you waste too much time, and should be directing you towards more fruitful options if you're floundering. As a goal we want to hire people who are better than half the people already employed by the company, which is admittedly kind of pie-in-the-sky grandiose, but really do want to keep making the company better. At the same time we absolutely do not want to make candidates unhappy or feel bad about their interviews - if you leave an Amazon interview thinking the interviewer was an asshole or incompetant, you really should tell the recruiter (after hearing the decision if you're nervous).
I don't think it's fair to compare this problem to an "estimate the weight of a battleship full of jellybeans" problem. I don't like those wildly open-ended and handwavey estimation problems either, and we generally don't allow questions like that on interviews, both because candidates distrust them, and because there's very little we can concretely evaluate you on because of how poorly defined they are.
I've read your other response, and while it's a reasonable thought, it definitely doesn't make more sense than asking an abstract algorithm design question, for two reasons:
The algorithm interviews are not the only interviews, there are other interviews better suited to asking your type of question:
We will ask the candidate to discuss their past work and describe a project and problem they solved which they found interesting, which is a much less abstract and more contextual opportunity for the candidate to describe his problem-solving.
We will ask larger scale system design or bar-raising questions too, where you'll get more and more context. For instance on my interview, on interviewer started with asking me to design a simple messaging system. I did, assuming it was two processes communicating. He then said "What if the processes were on different computers?" I hastily adjusted my solution. Then over the next 40 minutes he threw more and wrenches in my solutions by adding more and more unanticipated issues (multiple consumers, multiple producers, unreliable networks, unreliable persistence, unreliable machines, unreliable timing, race conditions, distributed deadlocks). I thought I was bombing the question horribly, because I never got to an answer that he said "Yeah that's right" like on the previous interviews. Only after getting hired and working on these systems did I finally realize that he wasn't just picking holes in my solutions, he was building me up through all the things that go wrong in distributed systems - there wasn't really a correct answer, he was just seeing how I reacted to each new problem. I left the interview thinking I'd failed because of that last interviewer, then found out I was hired, and (much to my initial horror) that guy was my new boss. I learned more from the first 2 weeks under him than on my previous 5 years of fulltime work. And the project we were working on involved all the problems he threw into my interview question on a daily basis, so it was spot-on in preparing me to work for him.
We can't really ask you to solve a problem we actually have, both because it would mean explaining proprietary stuff to you, and (more importantly) because there's too much context to explain that is useless to you - to ask a question about the design problems I've had the past week, I'd need to explain a bunch of interrelated distributed systems that most of the rest of Amazon doesn't know exists, never mind external candidates - it would just be a waste of your and my time, and not test anything that can't be tested with a generalized abstract question.
2
u/diverightin63 Oct 31 '13
While I find these kinds of interviews stupid, I do wonder how exactly a company the size of Twitter or Amazon can approach interviews, seeing as a bad hire could do some major reputation damage if there is a bug big enough.
I hope I don't have to deal with interviews like this myself, but who knows.
0
u/soviyet Oct 31 '13 edited Oct 31 '13
I don't think its that hard though, especially for a company that's been around as long as Twitter. Surely some shit has hit the fan, some problem has arisen, and surely they've fixed it somehow.
Take one of those problems and ask a potential hire "what would you have done?" It's a far better approach because a.) it isn't some obscure meaningless riddle that has absolutely no real world application, b.) the answer, or at least one of the answers, exists and has been proven within the company, and c.) it is easier to compare the problem solving process of the candidate to the team that already is in place. Does he solve the problem the same way using the same process? Does he do it better? Does he approach the problem in a way that the rest of the team would be annoyed by, confused by, threatened by, or otherwise frustrated by? Does he solve the problem at all?
The odds are also incredibly small that a potential hire has any idea the problem ever existed within the organization, much less the solution to the problem, unlike one of these shitty riddles that gets posted all over the Internet every time someone walks out of an interview.
47
u/eean Oct 30 '13
I am upset that the interviewer didn't ask me the right questions to guide me towards the right train of thought.
Is this guy trying to be fodder for yet another "Gen Y entitlement" article? :S
16
u/FeepingCreature Oct 30 '13
Well, that's what you're supposed to do in that kind of interview, no? The point is not to solve the riddle, the point is to see the dev's process. There's no point to watching him bash his head against a dead-end solution for half an hour; you don't learn much that way and you risk making him go off and work for a different company.
0
u/eean Oct 30 '13
Yes true, that's the idea*. Where the entitlement comes in is that he writes a whole blog about it. He is upset at the injustice of the failed interview, he isn't upset that the Twitter interview process isn't the best it could be.
*(Though IMO this sort of interview isn't great, the behavioral interview that tangents into technical discussion is better. I don't really buy the 'watch the dev work it out' as being useful, though for sure some coding is good to assess specific tech skills.)
27
-9
4
u/strattonbrazil Oct 30 '13
I don't know why Justin told me "this should work," when my solution in fact didn't.
I had a similar situation in an interview. I did the problem fine and when the interview asked the runtime, I said "log n"--it was related to search time of a particular tree--which he said was correct after he stopped for a second to think. I walked out of the interview realizing my error and wondering if the interviewer would figure it out. Maybe he was a little intimidated by me and probably thought, "Yeah, log n sounds right. It's a tree and I hear about log(n) stuff with trees." Makes me think that when we interview someone have some smart employees in the room to verify the certain answers. Especially for runtime efficiency where it's a little harder to walk the interviewer through it. Or at least have the answers on hand and just note what the candidate said for review.
3
u/abecedarius Oct 30 '13
Assuming nonnegative heights for convenience:
def pour_volume(heights):
return sum(max(0, min(hl, hr) - h)
for h, hl, hr in zip(heights,
climb(heights),
reversed(list(climb(list(reversed(heights)))))))
def climb(heights):
level = 0
for h, h1 in zip(heights, heights[1:]+[0]):
if h1 < h: level = max(level, h)
yield level3
u/wanderingbort Nov 01 '13
I am drunk at bar.
The multi-decade career I've had in software, which ranges from linux kernel development to assembly level graphics programming for AAA home gaming consoles, leaves me unable to immediately intuit an answer to this question.
If an impaired veteran may not pass your entry level interview question without deeper thought than beer allows... perhaps you are failing your role as a judge of talent.
4
u/fonograph Oct 30 '13
Reading this shit just makes me so very glad I don't work for a major tech company.
11
Oct 31 '13
"Congratulations! you solved the riddle which puts you in the top 0.1% of programmers!
Here's your cube, you'll start work on maintaining our ad delivery system on Monday!"
2
u/colly_wolly Oct 30 '13
Kind of thing one day the solution may pop into my head, and another it wouldn't.
I usually find thinking about a solution to a problem like this is a better approach than hammering out code straight away (as in an interview situation).
2
4
u/imright_anduknowit Oct 30 '13
WHY OH WHY are these questions still being asked in interviews?!?!?
Your ability to do this problem doesn't tell me much about you. Not in the short period you're given with no resources in a high pressure situation.
I'd rather give a real problems that I'm having or one I solved recently? Then I'd look to see if you dove into a solution (inexperienced) or started asking more questions (experienced).
I'm interested in how you think about the problem MORE SO than how you think about the solution. Because if you've asked the wrong questions, then who cares what the answers are. I blame 16 years of "schooling" for this mental disease.
8
Oct 30 '13
Isn't that exactly what the interviewers are doing by giving these problems? They want to see the thought process you use to get to the solution, including the questions you ask along the way. Also, these algorithmic type questions are reasonably good proxies for your ability to reason about complex engineering problems. They're not just a fad - if they were, then Google, Microsoft etc would no longer be using them. The fact that algorithms questions are still the preferred interview technique (at least for a first interview) among top companies suggests that they work well for differentiating candidates.
2
u/imright_anduknowit Oct 30 '13
12
u/ueberbobo Oct 30 '13
That pertains to questions like 'How many golf balls does it take to filll a bus?'. This is a (IMO) fairly simple question on algorithm design.
There is a certain element of luck though. You might have solved this specific problem before, or you might get stuck even if you're smart. You'd need multiple questions like this to assess skill in this area, and yes there are many more elements to software engineering.
2
Oct 31 '13
Your link is down for me, so I'm not sure what a crazy interview question is. This is a small algorithmic problem, and candidates are expected to explain the solution and write code to solve it in about 30min over the phone. This is identical to the first interview for an engineering job at Google right now .
2
u/alienangel2 Oct 31 '13
I'm interested in how you think about the problem MORE SO than how you think about the solution.
That's exactly what these questions are trying to do, see how you think about problems and how you go about solving them, and finally how you go about evaluating your potential solution.
I'd rather give a real problems that I'm having or one I solved recently? Then I'd look to see if you dove into a solution (inexperienced) or started asking more questions (experienced).
Because confusing you with completely proprietary terms in a problem space you've had no exposure to would be a waste of time, and unfair?
Look, Twitter does not care about calculating the volume of puddles. The question is there to evaluate how you think. That and how well you communicate and perform under (in this case very minor) stress are what we care about. If you're complaining that the interview doesn't tell us anything about what your life goals are and what you think your biggest weakness is, fine, it doesn't, mostly because we don't care about that, none of that is job relevant. We want to know if you'll be useful member of the team when we have a problem to solve and need ideas on how to solve it efficiently and correctly.
-1
u/nashef Oct 31 '13
Because the answer is mathematically simple and obvious. But there is no way to code the answer without solving the math problem. Mathematical skill corresponds to software engineering skill very tightly.
0
u/imright_anduknowit Nov 01 '13
I'm guessing it's only simple and obvious IF you've already solved problems like this. I've been solving simple to complex problems in both engineering and design for 32 years now and this problem seems purely arbitrary.
Frankly, I haven't spent 1 calorie to solve this but imagine if I were motivated to solve this, it wouldn't be hard.
The problem is I cannot tell very much about how you think by giving you puzzles. Unless, of course, you're job is a puzzle and riddle solver.
Here's a more real world problem: You have a user who runs a process on your website that takes minutes when you know it should take seconds. How do you go about troubleshooting the problem and eventually fixing it?
That's completely open-ended leaving plenty of room for learning about how the applicant thinks. And it's more realistic WITH NO RIGHT ANSWER.
Problems with no right answer tell me more about the applicant than the question that Twitter asked. In fact, I'd be so bold (and perhaps wrong) to say that anyone who would ask this type of question should examine their ego.
1
1
u/old_to_me_downvoter Oct 31 '13
How lucky/talented is this person?
I'm pretty sure both Amazon and Twitter would look at my skills and figuratively toss me off campus for looking like a homeless guy.
1
u/Enord92 Oct 31 '13
This was pretty much my exact experience interviewing at Amazon for an intern position. I was given two "puzzles" to solve after answering a series of CS Theory questions. I breezed through the theory questions and was okay with the first puzzle, but for whatever reason I simply could not understand the second puzzle. It had to do with stacks and queues though I can't remember the specific question. For the entire time I simply couldn't understand what he was asking me to do. There was a bit of a language barrier which certainly did not help but I've always wondered whether not being able to answer that in any fashion was the real nail in the coffin for not being offered the position. It's a shame it ended that way I would love another opportunity for it.
1
u/xoogl3 Nov 03 '13
The blog post doesn't go into details of what happened after the phone interview. If all contact with mobby1982 was simply discarded after this interaction, that just highlights the terrible way recruiting for engineering is done in typical valley companies.
I, for one, would have strongly considered OP for a further in-person interview after this interaction. My company (literally, my company, I started it) is doing interesting stuff in the mobile systems arena (not app work, more lower level systems work ... the really interesting stuff :-) and I detest this kind of opaque interviewing tactics. And yes, we're hiring.
1
Nov 04 '13 edited Nov 04 '13
It seems like a reasonable problem if it's explicit that water will move as far left and as far right as possible. If it can reach a drain like this, then it will leak out. I couldn't quite make sense of what the blog writer wrote but this is my idea of the problem. My solution is in O(n).
Water can only move left, right, or down. We can pretend that there's a drain next to the first wall (the 0th index in the list we have) and a drain next to the farthest wall. Then, a droplet of water will leak out of a pit if and only if there exists a path (composed of going left, right, and down-- no up because we pretend there's gravity) such that it can reach the drain. Going down is irrelevant because if we can go down, then there's going to be a drop of water below us already that took up that spot.
Let HEIGHTS be the given list of wall heights. Mathematically, a droplet of water at height 'h' over the wall at index 'i' can escape if and only if ((∀j, 0<=j<i, HEIGHTS[j] < h) or ( ∀j', LEN(HEIGHTS)>=j'>i, HEIGHTS[j'] < h))).
This is the same as finding the maximum wall height for all walls from 0 to i-1 and finding the maximum wall heights for all walls from i+1 to LEN(HEIGHT) and finding how much water can stay in by seeing if MIN(max height to left, max height to right) allows water to leak out.
You can easily do this by keeping track of the current maximum at each index from left to right, and the current maximum at each index from right to left. Then the amount of water that stays above a wall at index 'i' is MIN(max height to left of i, max height to right of i) - HEIGHTS[i], if HEIGHTS[i] < MIN(max height to left of i, max height to right of i).
1
1
Oct 30 '13
Can I just while loop it through and every time the index value is lower than the previous and next index value I just add + one to a counter?
3
u/oslash Oct 30 '13
If you want to count the number of columns that are lower than both neighbours instead of solving the actual problem, you can certainly do that!
1
Oct 30 '13
I mean i would even out the shortest column to the second highest vomun from the three.
4 2 6 so i would get 4 4 6. So 2 puddles.
1
u/oslash Oct 30 '13
Ah, you meant run that while loop for each column? That's unnecessary; if you already know the heights of the column and of both neighbours, you can compute the difference directly; there's nothing to count. You could make that work somehow, but you'd end up with an algorithm that is more complex than what you described so far; we'd have to consider the entire thing in order to assess correctness.
As it is, it doesn't work at all: You can turn 4 2 6 into 4 4 6 and count two units of volume (note that in the article, 'puddle' means 'contiguous volume of water'), but consider the case 4 2 2 6. Or 8 4 2 6.
1
1
u/Djebir Oct 31 '13 edited Oct 31 '13
So ...
[2, 5, 1, 2, 3, 4, 7, 7, 6].reduce(function(accumulator, height){
if(height < accumulator.lastHighest){
accumulator.workingVolume += accumulator.lastHighest-height;
}else{ // height >== accumulator.lastHighest
accumulator.currentVolume += accumulator.workingVolume;
accumulator.workingVolume = 0;
accumulator.lastHighest = height;
}
return accumulator;
}, {
lastHighest: 0,
currentVolume: 0,
workingVolume: 0
})... would work. Auuuugh, if I can get that that quickly, given the number of interviews I bomb, I must interview absolutely terribly.
Edit: sorry about the bad formatting; should be fixed now.
Edit2: or maybe my implementation is also broken and I'm also a terrible coder too :| welp the world could always use another plumber.
Edit3: removed excessive complaining.
1
u/throwawaylms Oct 31 '13
Now try it for [6, 7, 7, 4, 3, 2, 1, 5, 2].
Since water can shed off either side you need to work 2 accumulators, one from each side.
-1
0
u/schwiz Oct 30 '13
Can anyone else not click the link to the gist solution? Chrome on mac pukes all over itself when I click it.
0
Oct 31 '13
Obviously Twitter doesn't have the greatest engineers since they can't figure out how to take in more than 160 characters of data? #AmIRight
-5
u/bro-away- Oct 30 '13
It's kind of awkward he's writing this when he isn't done at Amazon.
I'm the last person who trumpets company loyalty but do we have to let everyone know we're trying to work elsewhere? I'm sure he worked with full time people on the Amazon team who might take offense to this. I would definitely feel like I have less obligation on a personal level to an intern who blogs about the other companies he wishes he could work for.
It's an internship, I get it, it's interesting--but save stuff like this for when you are done at the company.
12
u/eean Oct 30 '13
I really see no problem with that since it's an internship. It's not at all "disloyal". I can't imagine taking offense if I was working with an intern discussing where they were looking for a job. I'd probably even ask what their plans were.
That said I think it's weird posting your interview experience while naming names, from the dept. of do your professor a favor and don't give out test questions.
0
u/bro-away- Oct 30 '13
I meant loyalty in a person to person sense and like I said I don't have much company loyalty.
Fantasizing about your missed better opportunities on your blog is more of a dick move than actually getting the job and leaving. From one team member to another, I would not like it. I can't be the only crazy who holds this opinion--hopefully no one else on his team does! I don't get what he benefits by writing this.
1
u/intellimouse Oct 31 '13
The "What if?" stuff is a bit much yes. But we know interns work at other places, hell half the full-time employees wander around in Google and Facebook t-shirts too. Half the ex-interns I still have on Linkedin are or have been at different tech companies after us - I don't think anyone is going to go looking for intern blogs and try to block their offers over it, unless there's something really venomously negative about them.
0
Oct 30 '13
[deleted]
-1
-3
u/bro-away- Oct 30 '13
You are completely missing the point... I am looking at it from a team member perspective. I have quit many jobs for little more than a decent raise. It is a personal relationship--and the decision to write this article can cause others to feel negatively toward you.
0
u/hive_worker Oct 30 '13
Wouldn't the only solution be to find the absolute maximum, then divide into two subarrays, and recursively find maximum values of each outter subarray?
I didn't explain this very well lol
3
u/oslash Oct 30 '13
Why should this be the only solution? Did you find something wrong with the two solutions described in the article? ;p
Bonus tip: If there's a recursive solution, you can be pretty sure there's an iterative one as well.
Extra bonus tip: If the solution is an algorithm, there are a lot of other algorithms that will compute the same result.
1
u/hive_worker Oct 30 '13
True there's an iterative solution but I was just considering that the same as my recursive one. different implementations of the same idea.
I don't have time to fully flesh any of this out but the solution in the linked article seems like it would only work for the case of a single pool.
2
u/oslash Oct 30 '13
different implementations of the same idea
Agreed, works for me.
the solution in the linked article seems like it would only work for the case of a single pool
It does work in the general case.
0
u/netherfiend Oct 30 '13
hmmm, attempted this problem before reading your solutions... I feel like I got something pretty solid here with stacks, tested a few random arrays
0
u/jptman Oct 30 '13
Interesting Problem. I can think of a linear solution that makes intuitive sense to me. Basically, you find the first "wall" (next height is lower than the current). Then, you keep track of local maximas until you hit a height that's higher than the first wall or you reach the end. If you reach the end, the last local maxima you found was the last wall. Then, you Find the area inside the two walls ( min(first wall, second wall) * width (number of indexes between the two walls) ) and subtract the area of the walls from this. You can keep a running tally of both these so that you don't need to scan back. Repeat steps until you reach the end.
Not sure how pretty this will look when being implemented though.
1
u/gbs5009 Oct 31 '13
That's not quite going to work, because there may be local maxima after your last 'wall' that would still trap water.
1
u/jptman Oct 31 '13
If there's no "wall" on the right, does it still hold water? I may have misunderstood, but I thought the right hand edge doesn't count as a "wall".
1
u/gbs5009 Oct 31 '13
I interpreted everything undefined as zero too. I didn't really phrase my objection well, let me try a diagram instead.
O O O O O O O OOOOOOOOOYou have this situation... there's nothing higher than the first peak, so you're going to cut over to the local maxima on the right, measure it back to the first peak, and calculate the wrong answer.
1
u/jptman Nov 01 '13
Thanks for the diagram! I see what you mean. I don't know if I had thought of this situation, but the last step was to repeat the steps from the last wall. So, that should give the correct answer incidentally. But it's no longer an O(N) algorithm and there seem to be much better ways of doing it.
-10
u/Website_Mirror_Bot Oct 30 '13
Hello! I'm a bot who mirrors websites if they go down due to being posted on reddit.
Here is a screenshot of the website.
Please feel free to PM me your comments/suggestions/hatemail.
4
u/JoeOfTex Oct 30 '13
Such a great screenshot!
You may need to set your screencap to wait until all JS code under document load are completed.
-1
u/realteh Oct 30 '13 edited Oct 31 '13
create a list of 2-tuples (height, index)
use heap property to pop largest two elements with height h0 and h1 at index i0 and i1
sum(h1 - height(x) for x in range(i0+1 to i1-1))
...
profit!
Edit: I'm stupid and this is wrong.
82
u/MyNameIsFuchs Oct 30 '13 edited Oct 30 '13
FYI this algorithm is called the "Water filling algorithm" and is used extensively in Communications to optimize the allocation power for channels.
You can get a solution with simple Lagrangian method (which is a linear complexity solution).
http://www.eecs.berkeley.edu/~dtse/Chapters_PDF/Fundamentals_Wireless_Communication_chapter5.pdf (pages 183 - 185)