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
-
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
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
-
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
lol, I worked at a community college and that adage is soo true. Those who can do, Those who cannot do teach, those who cannot teach manage, those who cannot manage sell, those who cannot sell. Well there is always politics and law.
To err is human to really mess up you need a computer
-
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:
Anyone else agree this is fundamentally broken?
100% agree. I experienced something similar where I had a phone interview which was supposed to last 15 min (as a screening) and went on for over an hour and a half as various members pelted me with specific questions. Finally, they hit on a topic I didn't have experience with and I said so and they went cold. Whatevs! The thing is you could literally ask Einstein a particular question that even he didn't have experience with.
Charles Caleb Colton, (1780- 1832):
Examinations are formidable even to the best prepared, for the greatest fool may ask more than the wisest man can answer.
-
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 had a similar experience: take a text and embed it in a string with a '*' at char 1 (counting from 1) and a '*' in char 14 with the text in the middle padded (if necessary) with spaces using a language whose only string function was LENGTH. I wrote a one line solution that took a max of 4 comparisons and was told it was wrong. Why? It did not match the question setters solution (which was 12 lines and always used 12 comparisons). As the interviewer said to me "There are two solutions: my way [i.e. his way] and the wrong way".
-
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, there is this incredibly inefficient solution:
int[] data = new int[] { 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0 };
int y = 0;
var result = data.OrderBy(d => d == 0 ? int.MaxValue : y++);It works, but ... it's pretty horrible! :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
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 should say I've been in management before. I'm not anti-PHB. I've hired people. I've managed people. I love business folks. More developers need to mature and learn the perspective of managers. And yes, there are those managers who seek to do nothing but manage and boss people around that should never be hired. But, there are a ton of great ones out there that used to be devs, etc. Anyway, my recruiter was nothing short of superb here. The interview was super great and friendly. It's just fundamentally broken in the way we go about it.
Jeremy Falcon
-
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
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!
-
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
A few moments though gave me this:
int[] data = new int[] { 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0 };
int outp = 0;
for (int inp = 0; inp < data.Length; inp++)
{
int d = data[inp];
if (d != 0)
{
data[outp++] = d;
}
}
while (outp < data.Length)
{
data[outp++] = 0;
}"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
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
yep, I was once asked a question of if you can only have two variables how do you switch their values. I was in a peevy mood(due to idiot I was interviewing with) and didn't really think before I answered. But I essentially said never happens in real life and why the heck do you want too and dude it really isn't possible. Once I thought about it for a second(a week later) I understood it was just a theoretical question. But hell. a = 15 b = 5 a= a+b b = a-b a = a-b But would that ever happen in a real life work environment?
To err is human to really mess up you need a computer
-
Jeremy Falcon wrote:
Anyone else agree this is fundamentally broken?
100% agree. I experienced something similar where I had a phone interview which was supposed to last 15 min (as a screening) and went on for over an hour and a half as various members pelted me with specific questions. Finally, they hit on a topic I didn't have experience with and I said so and they went cold. Whatevs! The thing is you could literally ask Einstein a particular question that even he didn't have experience with.
Charles Caleb Colton, (1780- 1832):
Examinations are formidable even to the best prepared, for the greatest fool may ask more than the wisest man can answer.
raddevus wrote:
Finally, they hit on a topic I didn't have experience with and I said so and they went cold.
In my experience... you want honest people. Nobody knows everything... it's impossible. I've managed devs before I helped train how to do interviews for. The vast majority of them just Google questions to ask and that's that.
raddevus wrote:
The thing is you could literally ask Einstein a particular question that even he didn't have experience with.
Exactly
Jeremy Falcon
-
I should say I've been in management before. I'm not anti-PHB. I've hired people. I've managed people. I love business folks. More developers need to mature and learn the perspective of managers. And yes, there are those managers who seek to do nothing but manage and boss people around that should never be hired. But, there are a ton of great ones out there that used to be devs, etc. Anyway, my recruiter was nothing short of superb here. The interview was super great and friendly. It's just fundamentally broken in the way we go about it.
Jeremy Falcon
My "boss" - at the director's level, is great. Works hard and really knows his stuff (DBA). I'd give it better than even money that, were he able to avoid prison he'd exterminate most of his peers (and above). Some do, in fact, earn their way to management. From my observation, whether in private sector or government (and even social organizations) there are those who want to get to the top - and they're the ones who common sense promotes that one least wants to get there. Remember - management is an entire curriculum at most universities. There's little to expect from that since the paradigms are style-driven. Add in some acronyms and made-up words and you have a cult of . . . . well, read Dilbert [^] some more.
"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
-
Well, there is this incredibly inefficient solution:
int[] data = new int[] { 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0 };
int y = 0;
var result = data.OrderBy(d => d == 0 ? int.MaxValue : y++);It works, but ... it's pretty horrible! :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Oh you fancy kids and your LINQ statements. ;P It was for a frontend position, so I used JavaScript. There are some LINQ libs for JavaScript actually, but they are slow as dirt and nobody uses them.
Jeremy Falcon
-
A few moments though gave me this:
int[] data = new int[] { 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0 };
int outp = 0;
for (int inp = 0; inp < data.Length; inp++)
{
int d = data[inp];
if (d != 0)
{
data[outp++] = d;
}
}
while (outp < data.Length)
{
data[outp++] = 0;
}"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Right... that's the first take, but I used two arrays to pull it off to avoid the second loop.
Jeremy Falcon
-
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 coding interviews are fundamentally broken?
Perhaps, but of the ones I've partaken in, it may also be me. With three decades under my belt, there's not much I can't do, yet I feel totally inept when asked "How would you solve" questions.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
yep, I was once asked a question of if you can only have two variables how do you switch their values. I was in a peevy mood(due to idiot I was interviewing with) and didn't really think before I answered. But I essentially said never happens in real life and why the heck do you want too and dude it really isn't possible. Once I thought about it for a second(a week later) I understood it was just a theoretical question. But hell. a = 15 b = 5 a= a+b b = a-b a = a-b But would that ever happen in a real life work environment?
To err is human to really mess up you need a computer
rnbergren wrote:
But would that ever happen in a real life work environment?
That's the point. If this was systems programming or device programming I could see that. But for your typical LOB app...
Jeremy Falcon
-
I had a similar experience: take a text and embed it in a string with a '*' at char 1 (counting from 1) and a '*' in char 14 with the text in the middle padded (if necessary) with spaces using a language whose only string function was LENGTH. I wrote a one line solution that took a max of 4 comparisons and was told it was wrong. Why? It did not match the question setters solution (which was 12 lines and always used 12 comparisons). As the interviewer said to me "There are two solutions: my way [i.e. his way] and the wrong way".
-
My "boss" - at the director's level, is great. Works hard and really knows his stuff (DBA). I'd give it better than even money that, were he able to avoid prison he'd exterminate most of his peers (and above). Some do, in fact, earn their way to management. From my observation, whether in private sector or government (and even social organizations) there are those who want to get to the top - and they're the ones who common sense promotes that one least wants to get there. Remember - management is an entire curriculum at most universities. There's little to expect from that since the paradigms are style-driven. Add in some acronyms and made-up words and you have a cult of . . . . well, read Dilbert [^] some more.
"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 had a similar experience: take a text and embed it in a string with a '*' at char 1 (counting from 1) and a '*' in char 14 with the text in the middle padded (if necessary) with spaces using a language whose only string function was LENGTH. I wrote a one line solution that took a max of 4 comparisons and was told it was wrong. Why? It did not match the question setters solution (which was 12 lines and always used 12 comparisons). As the interviewer said to me "There are two solutions: my way [i.e. his way] and the wrong way".
:doh: :doh: :doh: :doh:
Jeremy Falcon
-
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 think after years you become so focused on real problems and real solutions, that such out-of-the-world questions are irritating you so much you not even feel to do a real effort... You take it as an insult to your developer intelligence :laugh:
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012