25 years of programming reduced to a question.
-
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
-
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
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)
-
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?
-
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.
-
Hey, are you my alter ego? 8) I've just thought, maybe old programmers never die, they just become VBA devs... Like you, I started with FORTRAN; then Algol68, Algol60, Pascal, assembler, C, C++, Java, PHP and a few others; now HTML5/CSS/JS, SQL, Python and VBA (Access). By the time I reach 70, will I be reduced to Scratch? HA HA Bonk!
At 72, I've been reduced to Angular. And C#. And C++. And Python. I will not willingly admit to any Java competency. I've got guys in the department to do that dirty work.
-
That's a link I've bookmarked and visit daily. (hint hint hint)
"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
-
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
:thumbsup: Great post! So the short of it is, they asked you to solve a CS exam question on the spot and you did...your solution provided the correct output but they passed on you anyway. :confused: I once believed that if my company ever failed that I could find another job easily. (21+ years of LOB apps for desktop and web) I thought that a resume with dozens of successful (still in use and still generating income) applications might be some strong evidence that I know what I'm doing. After all, programming is just about solving problems using the tools at hand...right? :sigh: After reading this post, I see that I'd likely not pass this type of interview...but that's OK...we're expanding and very soon I'll likely be faced with hiring a jr. dev for some of the grunt work. :| Welcome back Jeremy! :)
"Go forth into the source" - Neal Morse
-
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
Any test that does not allow you to google the optimal answer to the specified problem is not a real world test and a flat waste of everybody's time. You should be allowed to google and rated on the answer you select from the search results. If you fail to google, you should be immediately disqualified.
-
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);sickfile wrote:
i could have never thought of the solution you found on the internet.
I honestly didn't find that on the Internet. I really did think of the code myself. The key to getting to that answer was thinking about the fact that you really just needed: 1. the list of all the values >0 2. the same number of zeroes at the end of the list (which are contained in the array)
sickfile wrote:
it's brilliant.
:-\ :-O Youre one-liners are very interesting. JS does allow you to do some interesting things grammatically. :)
-
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.
This is a fantastic post and I wish more companies would really see it this way. It is amazing that your company considered what they were doing to devs in interviews and tried a new way. Very cool!!! :thumbsup::thumbsup::thumbsup: If I just needed some code done then hire the best you can find (which means probably not in-house anyways, just go find someone on the web to do the work). However, what your company did was to build a real team of contributing individuals where people's input was respected. Amazing. I'd much rather hire: 1. the nicer / team-friendly / good-attitude candidate 2. who has good-enough skills 3. who is willing to grow and learn 4. who has energy! the desire to make things excellent I'd much rather hire that person than the "genius" who can pass all these freaking algorithm tests and is obnoxious.
-
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
Jeremy Falcon wrote:
Does anyone else think that's a fundamentally broken way to find a good programmer?
Yes, its fundamentally broken, but it cuts both ways. If they reject you because you didn't give the answer that they found by googling, instead assessing the answer you did give, do you really want to work with that team? If its some HR flunkie that filtering you out, what caliber of engineer are they like to have working for that company? If if the actual devs, how savvy must they be if they can't see past a googled programming problem answer? In either case, do you really want to be working with those developers? Of course, this only matters if you already have a paying job.
5G -- more lies faster.
-
don't you just love the way JS let's you express your thoughts?
:thumbsup:
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.
Everyone Googles stuff though this day and age. What we are expected to know is growing exponentially. Even the younger guys experience things like JavaScript fatigue. It's almost to the point it's getting out of control.
DumpsterJuice wrote:
I used to have to memorize the Parameters of built in Method calls.
Same here about IntelliSense. It's ubiquitous as an AC... we'll never not have it in humanity again... like never. Same goes for spell check.
DumpsterJuice wrote:
"10 years Experience in " ( technology that is not 10 years old)
:laugh:
Jeremy Falcon
-
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)
Agreed :thumbsup:
Jeremy Falcon
-
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.
NightPen wrote:
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.
You sir, deserve a +100 for this statement. It's true. For instance, I know I can run circles around most people with CSS. This is a frontend job after all. But I'd also like to have kids before I die. Life needs balance.
NightPen wrote:
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.
Agreed. Respect goes a long way.
Jeremy Falcon
-
This is a fantastic post and I wish more companies would really see it this way. It is amazing that your company considered what they were doing to devs in interviews and tried a new way. Very cool!!! :thumbsup::thumbsup::thumbsup: If I just needed some code done then hire the best you can find (which means probably not in-house anyways, just go find someone on the web to do the work). However, what your company did was to build a real team of contributing individuals where people's input was respected. Amazing. I'd much rather hire: 1. the nicer / team-friendly / good-attitude candidate 2. who has good-enough skills 3. who is willing to grow and learn 4. who has energy! the desire to make things excellent I'd much rather hire that person than the "genius" who can pass all these freaking algorithm tests and is obnoxious.
raddevus wrote:
I'd much rather hire that person than the "genius" who can pass all these freaking algorithm tests and is obnoxious.
Exactly... especially when they can't even get the job done because all they study is algorithms and not the tech being used. :thumbsup:
Jeremy Falcon