25 years of programming reduced to a question.
-
I once worked for a company where everyone was a developer (except for two people in administration). They had about 30 people. This was from 2014 to about 2017 (just saying, because you may get the idea I'm talking late 90's early 00's). Before I got to work there I got a questionnaire with questions like "what's the next number/figure in the sequence?", "what happens to a candle and a drop of mercury in an elevator that's going down at a certain speed?"(???) something with a sailboat and wind, one question where I had to make a basic HTML page, and two or three database design questions. I skipped the nonsense questions like the sailboat and mercury because I really don't know anything about sailing or friggin' mercury :confused: I somehow made a mistake in the database design, which was unfortunate. Anyway, I got the job and immediately noticed everyone's knowledge was stale. They were working on old languages and frameworks, two teams did EVERYTHING in Oracle (yes, EVERYTHING, if all you have is a hammer...), I got across JavaScript code that returned various types from the same 100+ lines function, despite everyone being an "Oracle expert" (they wrote their own Oracle management tool) I got some very strange looks when I asked about JOIN syntax and tracing, etc. The person who was in charge for keeping up with new technologies only shared the occasional Oracle update (he was in that everything Oracle team). The few good people all quit, save for one who has a family and makes good money there, although he once told me "my career is going backwards here, I'm currently doing Oracle and Delphi." I quit because my team was extremely toxic due to some people being stressed out because they couldn't keep up. I really don't know what their questionnaire was testing, but it wasn't quality in any way.
Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
-
Does anyone else think coding interviews are fundamentally broken? So like, literally I've been doing this (programming) my whole life. We can all go through our accolades I'm sure, but suffice it to say I've done some things over the years to help rebuild departments in large corporations to garner the attention of regional VPs, etc. as we all have. But, I say this because, two days ago, I had an interview with Unnamed Company That Rhymes With Acelook. Don't get me wrong, they were super friendly, and it was a great chat. But I was asked questions like...
Are you comfortable with writing APIs on the backend?
That's a generic question, so of course I say sure. To me this indicates the interviewer doesn't realize the best way to interview. No real probing... just questions like that. Ok, cool. Still was a great, super friendly chat. But, then the tech portion of it came up. I was asked this.../* given an array of random numbers, push all the zero's of a given array to the end of the array
for example, if the given arrays is [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0], it should be changed to [1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0]Example:
Input: [1, 2, 0, 4, 3, 0, 5, 0];
Output: [1, 2, 4, 3, 5, 0, 0];Input: [1, 2, 0, 0, 0, 3, 6];
Output: [1, 2, 3, 6, 0, 0, 0]; */Ok fine... I get how this game works. So, let's get cracking. The first solution I start with used two arrays. Cool, no biggie. But then the interviewer asked for me to do it in-place. Ok, fine. So, I write some code that is like a bubble sort that brute forced it (ie, nested loops). We all know that it sucks to have nested loops. Anyway, the interview was cut short and that was that. I look up the "official" solution online, and it's no better than my first attempt. In fact, my first attempt was quicker due to only one loop. The one I linked to was using two loops that just weren't nested. So, not only did my original solution avoid two loops (using more memory though), but I found a more elegant solution online and I just know if that interview wasn't cut short I could've tried something like this the third go-round...
void moveZeroes(vector& nums) {
for (int lastNonZeroFoundAt = 0, cur = 0; cur < nums.size(); cur++) {
if (nums[cur] != 0) {
swap(nums[lastNonZeroFoundAt++], nums[cur]);
}
}
}But since I didn't try something like this first, I got passed on. D
At times in my career I have been in charge of the interviewing. This is how I approached it: GOAL: "Can the person fit in with the group, and contribute". From the resume I glean; 1. I can see a lot of years of experience. (or perhaps "enough" years). 2. I see education. 3. I typically see a list of what the candidate feels is his core skills (they may not be in a technology that we use, because we are using something new) 4. I invite a few dev's to participate, with the only rule being "You cannot use Google to ask questions. (If you have to look it up, that is not fair). 5. The Goal is to get a feel for the candidate as a fellow team member. The Goal is NOT to humiliate, judge, or ask complex algorithms. I do not ask tech questions of a CS Grad, or post Grad. Guess what? They might get it wrong. So what? All this proves is you can ask anybody anything, and they MIGHT get it wrong. If the Candidate is not proficient it will be revealed. (Yes, this may wind up as an exercise in futility) -That's ok. I might even leave him on the team, and adjust to his/her abilities. For example - they be highly skilled in SQL, and less proficient in Angular. You are never going to find "The Golden Candidate". Work Ethic is what I look for. If you can bash your way to learning Angular, that is good enough. You can spend all your time humiliating people, or you can cut to the chase. Keep It Simple, keep it moving.
-
Does anyone else think coding interviews are fundamentally broken? So like, literally I've been doing this (programming) my whole life. We can all go through our accolades I'm sure, but suffice it to say I've done some things over the years to help rebuild departments in large corporations to garner the attention of regional VPs, etc. as we all have. But, I say this because, two days ago, I had an interview with Unnamed Company That Rhymes With Acelook. Don't get me wrong, they were super friendly, and it was a great chat. But I was asked questions like...
Are you comfortable with writing APIs on the backend?
That's a generic question, so of course I say sure. To me this indicates the interviewer doesn't realize the best way to interview. No real probing... just questions like that. Ok, cool. Still was a great, super friendly chat. But, then the tech portion of it came up. I was asked this.../* given an array of random numbers, push all the zero's of a given array to the end of the array
for example, if the given arrays is [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0], it should be changed to [1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0]Example:
Input: [1, 2, 0, 4, 3, 0, 5, 0];
Output: [1, 2, 4, 3, 5, 0, 0];Input: [1, 2, 0, 0, 0, 3, 6];
Output: [1, 2, 3, 6, 0, 0, 0]; */Ok fine... I get how this game works. So, let's get cracking. The first solution I start with used two arrays. Cool, no biggie. But then the interviewer asked for me to do it in-place. Ok, fine. So, I write some code that is like a bubble sort that brute forced it (ie, nested loops). We all know that it sucks to have nested loops. Anyway, the interview was cut short and that was that. I look up the "official" solution online, and it's no better than my first attempt. In fact, my first attempt was quicker due to only one loop. The one I linked to was using two loops that just weren't nested. So, not only did my original solution avoid two loops (using more memory though), but I found a more elegant solution online and I just know if that interview wasn't cut short I could've tried something like this the third go-round...
void moveZeroes(vector& nums) {
for (int lastNonZeroFoundAt = 0, cur = 0; cur < nums.size(); cur++) {
if (nums[cur] != 0) {
swap(nums[lastNonZeroFoundAt++], nums[cur]);
}
}
}But since I didn't try something like this first, I got passed on. D
Are you sure that was the reason you were passed on? Could it be an excuse rather than to say you were too old? Anyway I am glad I never had to undergo any test of programming skill in my entire 45 year career as a programmer. When I did change jobs I was accepted due to my reputation.
-
Interview I mostly bullshit, I totally agree! Often not done by the people who will work for you but by people who have no clue... with whimsical question either way... It highlights the following truism - being unprepared will guarantee you failure... - being well prepared will leave success to luck... To edge your luck a bit more one got also to work on social skill and self promotion! :p
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
Super Lloyd wrote:
self promotion
I think that's the key right there... maybe it's always been this way throughout history. It's certainly true today... if you don't promote yourself nobody cares. Regardless of how good you actually are.
Jeremy Falcon
-
Unfortunately life is a bit too much about getting the exact right answer, not on how you get there. :sigh: We've all been there. :-\
V.
Agreed. And overall it was a good experience... still makes you wonder why we put ourselves through that in this industry though.
Jeremy Falcon
-
I once worked for a company where everyone was a developer (except for two people in administration). They had about 30 people. This was from 2014 to about 2017 (just saying, because you may get the idea I'm talking late 90's early 00's). Before I got to work there I got a questionnaire with questions like "what's the next number/figure in the sequence?", "what happens to a candle and a drop of mercury in an elevator that's going down at a certain speed?"(???) something with a sailboat and wind, one question where I had to make a basic HTML page, and two or three database design questions. I skipped the nonsense questions like the sailboat and mercury because I really don't know anything about sailing or friggin' mercury :confused: I somehow made a mistake in the database design, which was unfortunate. Anyway, I got the job and immediately noticed everyone's knowledge was stale. They were working on old languages and frameworks, two teams did EVERYTHING in Oracle (yes, EVERYTHING, if all you have is a hammer...), I got across JavaScript code that returned various types from the same 100+ lines function, despite everyone being an "Oracle expert" (they wrote their own Oracle management tool) I got some very strange looks when I asked about JOIN syntax and tracing, etc. The person who was in charge for keeping up with new technologies only shared the occasional Oracle update (he was in that everything Oracle team). The few good people all quit, save for one who has a family and makes good money there, although he once told me "my career is going backwards here, I'm currently doing Oracle and Delphi." I quit because my team was extremely toxic due to some people being stressed out because they couldn't keep up. I really don't know what their questionnaire was testing, but it wasn't quality in any way.
Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
Sander Rossel wrote:
skipped the nonsense questions like the sailboat and mercury because I really don't know anything about sailing or friggin' mercury
:laugh: :laugh: :laugh: Ouch.
Sander Rossel wrote:
I quit because my team was extremely toxic due to some people being stressed out because they couldn't keep up.
Good move. You'll only end up hating tech that way if you stay in a toxic environment too long. We should be loving our work.
Jeremy Falcon
-
Some programming interviews are bad. Others are good. Let me flip the question on you: How would you interview a candidate?
"If we don't change direction, we'll end up where we're going"
That's a great question... I eluded to it in another response, but the gist of what I would do is two fold: This interview didn't really probe into my experience at all to get a feel for me. Verbally that is. The interviewer did actually go through my resume (most don't) so props to him. I can't repeat enough that both the recruiter and interviewer were great. I'd also ask more questions about what makes them tick as a person. Algorithms can be taught. Personality can't. Work ethic and drive can't. For the tech side, I'd have basic rudimentary questions to weed out the obvious ones that don't belong (difference between, let and const, etc.), mix them in with tougher ones (what is a weak reference in JS, etc.), and maybe an algo as a bonus. The reason I wouldn't have a one-and-done algorithm question in and of itself, is maybe that person sucks at them, but they are great at design. It's a frontend job, people gonna have difference strengths. But if you one and done based on an algo alone, you'd never know. It's not the whole picture, especially considering algorithms aren't real world 90% of the time. So, I wouldn't base my entire judgment on them. Anyway, not to sound sour over the experience. The folks were great.
Jeremy Falcon
-
Jeremy Falcon wrote:
And while you're at, can you stop space and time and develop the first programming language used on Mars and feed that back to us?
Well, we already have the first programming language to be used on Jupiter ([JOVIAL](https://en.wikipedia.org/wiki/JOVIAL)) :-\
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
Touché! :laugh:
Jeremy Falcon
-
At times in my career I have been in charge of the interviewing. This is how I approached it: GOAL: "Can the person fit in with the group, and contribute". From the resume I glean; 1. I can see a lot of years of experience. (or perhaps "enough" years). 2. I see education. 3. I typically see a list of what the candidate feels is his core skills (they may not be in a technology that we use, because we are using something new) 4. I invite a few dev's to participate, with the only rule being "You cannot use Google to ask questions. (If you have to look it up, that is not fair). 5. The Goal is to get a feel for the candidate as a fellow team member. The Goal is NOT to humiliate, judge, or ask complex algorithms. I do not ask tech questions of a CS Grad, or post Grad. Guess what? They might get it wrong. So what? All this proves is you can ask anybody anything, and they MIGHT get it wrong. If the Candidate is not proficient it will be revealed. (Yes, this may wind up as an exercise in futility) -That's ok. I might even leave him on the team, and adjust to his/her abilities. For example - they be highly skilled in SQL, and less proficient in Angular. You are never going to find "The Golden Candidate". Work Ethic is what I look for. If you can bash your way to learning Angular, that is good enough. You can spend all your time humiliating people, or you can cut to the chase. Keep It Simple, keep it moving.
Well said. You can always spot the folks here who have actual hiring experience.
DumpsterJuice wrote:
You are never going to find "The Golden Candidate".
It's like a relationship... there's no such thing as perfect. If you think that you're gonna die alone.
DumpsterJuice wrote:
Work Ethic is what I look for. If you can bash your way to learning Angular, that is good enough. You can spend all your time humiliating people, or you can cut to the chase.
Yeah exactly. Especially when most interviewers just Google stuff to ask before the interview anyway. For systems programming I do think algorithms are important actually. But for most LOB jobs... nope. In the past I've aimed for personality, work ethic, and overall competency. We can always Google the algorithms this day and age if we ever get stuck. You can't teach personality.
DumpsterJuice wrote:
Keep It Simple, keep it moving.
Yup. Anyone in this industry long enough knows that devs have the expectation you're not allowed to have a life or family. You're supposed to spend your life 24/7 behind the computer on the off chance someone asks you a question you may not know the answer too. Shudder the thought. It's sad really because those devs rarely learn how to actually work with actual humans.
Jeremy Falcon
-
Are you sure that was the reason you were passed on? Could it be an excuse rather than to say you were too old? Anyway I am glad I never had to undergo any test of programming skill in my entire 45 year career as a programmer. When I did change jobs I was accepted due to my reputation.
dshillito wrote:
Are you sure that was the reason you were passed on? Could it be an excuse rather than to say you were too old?
That's what I was told and I trust them. They were great people. If there was another reason besides that like ageism it would surprise me. I suppose one can never know 100% but I trust them.
dshillito wrote:
Anyway I am glad I never had to undergo any test of programming skill in my entire 45 year career as a programmer. When I did change jobs I was accepted due to my reputation.
That's a great point. In this day and age, one must market themselves. It's a skill I wish I knew a long time ago. Better late than never...
Jeremy Falcon
-
Of course it's broken - HR doesn't know anything about the job, so they tend to rely on things like automated scanners that look for the magic keywords in the resume. Then once you've managed to pass through that first filter, the next level of the challenge is getting past the human part of the HR process, where someone who has no idea what you do decides whether or not to pass you on to the actual person/people who needs the job done. Even when you get to that step, there's a fair chance that the manager you talk to doesn't really know what they need, depending on their background and, to some extent, how long it's been since they actually did any coding. And for the high profile darlings of the stock market, as you noted, it's then on to some test totally unrelated to the day-to-day duties you'd actually be performing. It's only when you've passed all of those ridiculous barriers to entry that you might (but only might!) talk to someone who actually knows what the job entails and may be competent to judge whether or not your skills would be a good fit. How else would I wind up as a VB.Net programmer and Excel VBA macro writer when my previous experience was 40+ years of first Fortran and then C in a succession of Unix/Ultrix/Linux environments? And I still tease them about the wisdom of hiring a then 62 year old programmer to replace the 65 year old guy who was retiring!
I have you beat....they hired a 64 year old to replace the 65 year old who is retiring at the end of September (that is, 4 more of his working days as I type this; he takes Fridays off)! The good news is that I LOVE this new job and my new boss is terrific! I used to be in IT and he was one of my users I supported. He rose up the ranks the old way...he earned it! He knows what it's like to be a developer. I also am now a database developer (VBA in Access) and I wasn't before I transferred departments (I was a Cache ObjectScript/MUMPS programmer for the IDX/GE Healthcare system we have/had (it was replaced with Epic which does not encourage programmers to muck with their system, so I morphed into a SQL writer...I MISS being a Cache ObjectScript/MUMPS programmer). Oh, he just logged on...time to go drain his brain and document his extensive processes so I can support them all.
-
Well the interview situation is a pretty good opportunity for you to interview them as well, so...
"If we don't change direction, we'll end up where we're going"
Yeah, that was only my second ever interview so I kind of lacked the courage. In a later interview I literally said, I'm here to judge you as much as I'm here so you can judge me. I think that caught them off guard :laugh:
Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
-
Well said. You can always spot the folks here who have actual hiring experience.
DumpsterJuice wrote:
You are never going to find "The Golden Candidate".
It's like a relationship... there's no such thing as perfect. If you think that you're gonna die alone.
DumpsterJuice wrote:
Work Ethic is what I look for. If you can bash your way to learning Angular, that is good enough. You can spend all your time humiliating people, or you can cut to the chase.
Yeah exactly. Especially when most interviewers just Google stuff to ask before the interview anyway. For systems programming I do think algorithms are important actually. But for most LOB jobs... nope. In the past I've aimed for personality, work ethic, and overall competency. We can always Google the algorithms this day and age if we ever get stuck. You can't teach personality.
DumpsterJuice wrote:
Keep It Simple, keep it moving.
Yup. Anyone in this industry long enough knows that devs have the expectation you're not allowed to have a life or family. You're supposed to spend your life 24/7 behind the computer on the off chance someone asks you a question you may not know the answer too. Shudder the thought. It's sad really because those devs rarely learn how to actually work with actual humans.
Jeremy Falcon
If I am being honest, I incorporate Stack Overflow a lot in my daily work. If you take away the internet, I don't even have a help file in Visual Studio anymore. I am going out on a limb here, but its the truth - I can't really code well without access to the internet. My memory is not what it used to be, when we had no "Intelli-sense". I used to have to memorize the Parameters of built in Method calls. Guy come in, says "I don't have Angular experience, but it's because they only want people with experience" and this one: Requirements "10 years Experience in " ( technology that is not 10 years old) Keep It Simple, keep it moving.
-
Does anyone else think coding interviews are fundamentally broken? So like, literally I've been doing this (programming) my whole life. We can all go through our accolades I'm sure, but suffice it to say I've done some things over the years to help rebuild departments in large corporations to garner the attention of regional VPs, etc. as we all have. But, I say this because, two days ago, I had an interview with Unnamed Company That Rhymes With Acelook. Don't get me wrong, they were super friendly, and it was a great chat. But I was asked questions like...
Are you comfortable with writing APIs on the backend?
That's a generic question, so of course I say sure. To me this indicates the interviewer doesn't realize the best way to interview. No real probing... just questions like that. Ok, cool. Still was a great, super friendly chat. But, then the tech portion of it came up. I was asked this.../* given an array of random numbers, push all the zero's of a given array to the end of the array
for example, if the given arrays is [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0], it should be changed to [1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0]Example:
Input: [1, 2, 0, 4, 3, 0, 5, 0];
Output: [1, 2, 4, 3, 5, 0, 0];Input: [1, 2, 0, 0, 0, 3, 6];
Output: [1, 2, 3, 6, 0, 0, 0]; */Ok fine... I get how this game works. So, let's get cracking. The first solution I start with used two arrays. Cool, no biggie. But then the interviewer asked for me to do it in-place. Ok, fine. So, I write some code that is like a bubble sort that brute forced it (ie, nested loops). We all know that it sucks to have nested loops. Anyway, the interview was cut short and that was that. I look up the "official" solution online, and it's no better than my first attempt. In fact, my first attempt was quicker due to only one loop. The one I linked to was using two loops that just weren't nested. So, not only did my original solution avoid two loops (using more memory though), but I found a more elegant solution online and I just know if that interview wasn't cut short I could've tried something like this the third go-round...
void moveZeroes(vector& nums) {
for (int lastNonZeroFoundAt = 0, cur = 0; cur < nums.size(); cur++) {
if (nums[cur] != 0) {
swap(nums[lastNonZeroFoundAt++], nums[cur]);
}
}
}But since I didn't try something like this first, I got passed on. D
-
Seriously, I was thinking about this and there is a cheat to the original instructions. At least in JavaScript. See they just said put all the zeroes at the end. Well. you can do that in one for loop... Each time through loop 1. splice off the 0 at its original location. 2. then push it onto the end Voila!
var data = [ 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0 ];
for (var x = 0;x
don't you just love the way JS let's you express your thoughts?
-
Does anyone else think coding interviews are fundamentally broken? So like, literally I've been doing this (programming) my whole life. We can all go through our accolades I'm sure, but suffice it to say I've done some things over the years to help rebuild departments in large corporations to garner the attention of regional VPs, etc. as we all have. But, I say this because, two days ago, I had an interview with Unnamed Company That Rhymes With Acelook. Don't get me wrong, they were super friendly, and it was a great chat. But I was asked questions like...
Are you comfortable with writing APIs on the backend?
That's a generic question, so of course I say sure. To me this indicates the interviewer doesn't realize the best way to interview. No real probing... just questions like that. Ok, cool. Still was a great, super friendly chat. But, then the tech portion of it came up. I was asked this.../* given an array of random numbers, push all the zero's of a given array to the end of the array
for example, if the given arrays is [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0], it should be changed to [1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0]Example:
Input: [1, 2, 0, 4, 3, 0, 5, 0];
Output: [1, 2, 4, 3, 5, 0, 0];Input: [1, 2, 0, 0, 0, 3, 6];
Output: [1, 2, 3, 6, 0, 0, 0]; */Ok fine... I get how this game works. So, let's get cracking. The first solution I start with used two arrays. Cool, no biggie. But then the interviewer asked for me to do it in-place. Ok, fine. So, I write some code that is like a bubble sort that brute forced it (ie, nested loops). We all know that it sucks to have nested loops. Anyway, the interview was cut short and that was that. I look up the "official" solution online, and it's no better than my first attempt. In fact, my first attempt was quicker due to only one loop. The one I linked to was using two loops that just weren't nested. So, not only did my original solution avoid two loops (using more memory though), but I found a more elegant solution online and I just know if that interview wasn't cut short I could've tried something like this the third go-round...
void moveZeroes(vector& nums) {
for (int lastNonZeroFoundAt = 0, cur = 0; cur < nums.size(); cur++) {
if (nums[cur] != 0) {
swap(nums[lastNonZeroFoundAt++], nums[cur]);
}
}
}But since I didn't try something like this first, I got passed on. D
I know exactly what you mean. It's fair to put newbies to the test like that and see how they approach a task, and whether they get to the actual result. But asking an experienced programmer is an insult. At the very least they should make sure that the interviewer or whoever else judges your results is equally experienced and able to appreciate what you're doing. And if they don't understand why you chose to approach the problem the way you did, they should be fair enough to ask why you did that, not require you to recreate the exact solution that's on their checklist.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
My extension to an old saw: "Those that cannot do teach." If that's too hard, there's always Management.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010
I flunked a job as Java instructor during a phone interview, because I had been teaching C++ and briefly got a small point mixed up between the languages, something I would have quickly corrected, if I had actually been coding an example.
-
Does anyone else think coding interviews are fundamentally broken? So like, literally I've been doing this (programming) my whole life. We can all go through our accolades I'm sure, but suffice it to say I've done some things over the years to help rebuild departments in large corporations to garner the attention of regional VPs, etc. as we all have. But, I say this because, two days ago, I had an interview with Unnamed Company That Rhymes With Acelook. Don't get me wrong, they were super friendly, and it was a great chat. But I was asked questions like...
Are you comfortable with writing APIs on the backend?
That's a generic question, so of course I say sure. To me this indicates the interviewer doesn't realize the best way to interview. No real probing... just questions like that. Ok, cool. Still was a great, super friendly chat. But, then the tech portion of it came up. I was asked this.../* given an array of random numbers, push all the zero's of a given array to the end of the array
for example, if the given arrays is [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0], it should be changed to [1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0]Example:
Input: [1, 2, 0, 4, 3, 0, 5, 0];
Output: [1, 2, 4, 3, 5, 0, 0];Input: [1, 2, 0, 0, 0, 3, 6];
Output: [1, 2, 3, 6, 0, 0, 0]; */Ok fine... I get how this game works. So, let's get cracking. The first solution I start with used two arrays. Cool, no biggie. But then the interviewer asked for me to do it in-place. Ok, fine. So, I write some code that is like a bubble sort that brute forced it (ie, nested loops). We all know that it sucks to have nested loops. Anyway, the interview was cut short and that was that. I look up the "official" solution online, and it's no better than my first attempt. In fact, my first attempt was quicker due to only one loop. The one I linked to was using two loops that just weren't nested. So, not only did my original solution avoid two loops (using more memory though), but I found a more elegant solution online and I just know if that interview wasn't cut short I could've tried something like this the third go-round...
void moveZeroes(vector& nums) {
for (int lastNonZeroFoundAt = 0, cur = 0; cur < nums.size(); cur++) {
if (nums[cur] != 0) {
swap(nums[lastNonZeroFoundAt++], nums[cur]);
}
}
}But since I didn't try something like this first, I got passed on. D
Most companies go out of business buy not hiring than by hiring. 30 years ago as a young developer, I bought into the hire only the best of the best. My team would punish the candidate with insane technical interviews. Naturally we did end up with some of the best devs but we rejected a ton of other devs that probably could have done the job. As an experiment many years ago we changed the hiring practice and if the developer had the basic skills we would sit down talk with them as if they were 'already' on the job. If they participated and started solving problems, coming up with solutions and contributing they were provisionally hired for 3 months. If they worked out during that time we hired them permanently. The results were amazing. Our rejection rate dropped to about 15% and we ended up with some of the best code in the company. In looking back on the process it is clear to me what changed. When you punish candidates you only get those candidates that are desperate enough or unsure enough of their own skills that they will put up with that abuse. When you talk to candidates as the professionals they are you get a whole new level up interaction and find out what you really need to know. Which only comes down to ONE thing: Will they work with your team and be a contributing member.
-
Does anyone else think coding interviews are fundamentally broken? So like, literally I've been doing this (programming) my whole life. We can all go through our accolades I'm sure, but suffice it to say I've done some things over the years to help rebuild departments in large corporations to garner the attention of regional VPs, etc. as we all have. But, I say this because, two days ago, I had an interview with Unnamed Company That Rhymes With Acelook. Don't get me wrong, they were super friendly, and it was a great chat. But I was asked questions like...
Are you comfortable with writing APIs on the backend?
That's a generic question, so of course I say sure. To me this indicates the interviewer doesn't realize the best way to interview. No real probing... just questions like that. Ok, cool. Still was a great, super friendly chat. But, then the tech portion of it came up. I was asked this.../* given an array of random numbers, push all the zero's of a given array to the end of the array
for example, if the given arrays is [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0], it should be changed to [1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0]Example:
Input: [1, 2, 0, 4, 3, 0, 5, 0];
Output: [1, 2, 4, 3, 5, 0, 0];Input: [1, 2, 0, 0, 0, 3, 6];
Output: [1, 2, 3, 6, 0, 0, 0]; */Ok fine... I get how this game works. So, let's get cracking. The first solution I start with used two arrays. Cool, no biggie. But then the interviewer asked for me to do it in-place. Ok, fine. So, I write some code that is like a bubble sort that brute forced it (ie, nested loops). We all know that it sucks to have nested loops. Anyway, the interview was cut short and that was that. I look up the "official" solution online, and it's no better than my first attempt. In fact, my first attempt was quicker due to only one loop. The one I linked to was using two loops that just weren't nested. So, not only did my original solution avoid two loops (using more memory though), but I found a more elegant solution online and I just know if that interview wasn't cut short I could've tried something like this the third go-round...
void moveZeroes(vector& nums) {
for (int lastNonZeroFoundAt = 0, cur = 0; cur < nums.size(); cur++) {
if (nums[cur] != 0) {
swap(nums[lastNonZeroFoundAt++], nums[cur]);
}
}
}But since I didn't try something like this first, I got passed on. D
the best i could get is a one liner on the same idea as @raddevus.
data = [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0];
for (var i = data.length - 2; i >= 0; i--) data.splice(i, !data[i]).length && data.push(0);all thanks to JavaScript. i could have never thought of the solution you found on the internet. it's brilliant. let's C
int d[] = {1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0}, *s = d + sizeof d / sizeof *d;
for (int *c = d, *l = d; c < s; c++) if (*c) *l ? *l++ : (*l++ = *c) && (*c = 0); -
Does anyone else think coding interviews are fundamentally broken? So like, literally I've been doing this (programming) my whole life. We can all go through our accolades I'm sure, but suffice it to say I've done some things over the years to help rebuild departments in large corporations to garner the attention of regional VPs, etc. as we all have. But, I say this because, two days ago, I had an interview with Unnamed Company That Rhymes With Acelook. Don't get me wrong, they were super friendly, and it was a great chat. But I was asked questions like...
Are you comfortable with writing APIs on the backend?
That's a generic question, so of course I say sure. To me this indicates the interviewer doesn't realize the best way to interview. No real probing... just questions like that. Ok, cool. Still was a great, super friendly chat. But, then the tech portion of it came up. I was asked this.../* given an array of random numbers, push all the zero's of a given array to the end of the array
for example, if the given arrays is [1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0], it should be changed to [1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0]Example:
Input: [1, 2, 0, 4, 3, 0, 5, 0];
Output: [1, 2, 4, 3, 5, 0, 0];Input: [1, 2, 0, 0, 0, 3, 6];
Output: [1, 2, 3, 6, 0, 0, 0]; */Ok fine... I get how this game works. So, let's get cracking. The first solution I start with used two arrays. Cool, no biggie. But then the interviewer asked for me to do it in-place. Ok, fine. So, I write some code that is like a bubble sort that brute forced it (ie, nested loops). We all know that it sucks to have nested loops. Anyway, the interview was cut short and that was that. I look up the "official" solution online, and it's no better than my first attempt. In fact, my first attempt was quicker due to only one loop. The one I linked to was using two loops that just weren't nested. So, not only did my original solution avoid two loops (using more memory though), but I found a more elegant solution online and I just know if that interview wasn't cut short I could've tried something like this the third go-round...
void moveZeroes(vector& nums) {
for (int lastNonZeroFoundAt = 0, cur = 0; cur < nums.size(); cur++) {
if (nums[cur] != 0) {
swap(nums[lastNonZeroFoundAt++], nums[cur]);
}
}
}But since I didn't try something like this first, I got passed on. D
I agree 200%. I got so frustrated with interviews; I even got up and walked out on a couple because of the arbitrary-stretched-to-the-point-of-WTF who the hell has used one of those [insert obscure programming theory] in code in the last 20 years. The disgust has been so acrid that I started re-evaluating my career choices. I got thrown into the deep end of a lot of projects and successfully swam out. No one in any interview asked about that. I've given interviews and usually just by talking to the applicant inside of a few minutes can pretty quickly tell if the individual is a bullshit artist or not.