Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. 25 years of programming reduced to a question.

25 years of programming reduced to a question.

Scheduled Pinned Locked Moved The Lounge
questionloungegraphicsgame-devhosting
121 Posts 46 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J 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

    R Offline
    R Offline
    rnbergren
    wrote on last edited by
    #10

    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

    J F G 3 Replies Last reply
    0
    • R raddevus

      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.

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #11

      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

      M 1 Reply Last reply
      0
      • J 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

        W Offline
        W Offline
        W Balboos GHB
        wrote on last edited by
        #12

        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.

        Ravings en masse^

        "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

        J 1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          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!

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #13

          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

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            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!

            J Offline
            J Offline
            Jeremy Falcon
            wrote on last edited by
            #14

            Right... that's the first take, but I used two arrays to pull it off to avoid the second loop.

            Jeremy Falcon

            R 1 Reply Last reply
            0
            • J 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

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #15

              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

              1 Reply Last reply
              0
              • R rnbergren

                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

                J Offline
                J Offline
                Jeremy Falcon
                wrote on last edited by
                #16

                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

                1 Reply Last reply
                0
                • J jsc42

                  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".

                  M Offline
                  M Offline
                  musefan
                  wrote on last edited by
                  #17

                  To be honest those are great interview questions. Makes it clear that you should pass and find another interview elsewhere.

                  1 Reply Last reply
                  0
                  • W W Balboos GHB

                    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.

                    Ravings en masse^

                    "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

                    J Offline
                    J Offline
                    Jeremy Falcon
                    wrote on last edited by
                    #18

                    W∴ Balboos, GHB wrote:

                    well, read Dilbert [^] some more.

                    :laugh: :laugh: :laugh: That link is sooooo true.

                    Jeremy Falcon

                    W 1 Reply Last reply
                    0
                    • J jsc42

                      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".

                      J Offline
                      J Offline
                      Jeremy Falcon
                      wrote on last edited by
                      #19

                      :doh: :doh: :doh: :doh:

                      Jeremy Falcon

                      1 Reply Last reply
                      0
                      • J 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

                        Kornfeld Eliyahu PeterK Offline
                        Kornfeld Eliyahu PeterK Offline
                        Kornfeld Eliyahu Peter
                        wrote on last edited by
                        #20

                        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

                        "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

                        J 1 Reply Last reply
                        0
                        • J 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

                          5 Offline
                          5 Offline
                          5teveH
                          wrote on last edited by
                          #21

                          Here's the problem: Most people involved in hiring, (HR and managers), wouldn't recognise talent if the candidate had it tattooed across their forehead. So they resort to 'mechanical' methods of selection. If anywhere needs the help of AI, it's recruitment - because the real stuff isn't in abundance!

                          J 2 Replies Last reply
                          0
                          • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

                            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

                            J Offline
                            J Offline
                            Jeremy Falcon
                            wrote on last edited by
                            #22

                            I must agree with this sentiment. :thumbsup:

                            Jeremy Falcon

                            1 Reply Last reply
                            0
                            • 5 5teveH

                              Here's the problem: Most people involved in hiring, (HR and managers), wouldn't recognise talent if the candidate had it tattooed across their forehead. So they resort to 'mechanical' methods of selection. If anywhere needs the help of AI, it's recruitment - because the real stuff isn't in abundance!

                              J Offline
                              J Offline
                              Jeremy Falcon
                              wrote on last edited by
                              #23

                              This isn't an anti-management or anti-interviewer thing. I've been in management. I've hired people. More developers need to understand the other side of life before casting judgment. Anyway, my recruiter was awesome. The interviewer was great too. Super friendly and knowledgeable. It was a great experience, just broken in the way we go about it.

                              Jeremy Falcon

                              1 Reply Last reply
                              0
                              • 5 5teveH

                                Here's the problem: Most people involved in hiring, (HR and managers), wouldn't recognise talent if the candidate had it tattooed across their forehead. So they resort to 'mechanical' methods of selection. If anywhere needs the help of AI, it's recruitment - because the real stuff isn't in abundance!

                                J Offline
                                J Offline
                                Jeremy Falcon
                                wrote on last edited by
                                #24

                                Btw, I do agree that a lot of recruiters and HR only go for the buzzword bingo game... but in this instance the recruiter was fantastic.

                                Jeremy Falcon

                                1 Reply Last reply
                                0
                                • J jsc42

                                  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".

                                  J Offline
                                  J Offline
                                  Johnny J
                                  wrote on last edited by
                                  #25

                                  Oh yeah. Everybody who has more than 25 years in programming knows that there is only ONE SOLUTION to every given problem. That's why our job is so easy. We just look up the right solution in our programmers handbook and off we go.... Sarcastic? Who, me? Nooooooooo! :doh:

                                  Anything that is unrelated to elephants is irrelephant
                                  Anonymous
                                  -----
                                  The problem with quotes on the internet is that you can never tell if they're genuine
                                  Winston Churchill, 1944
                                  -----
                                  Never argue with a fool. Onlookers may not be able to tell the difference.
                                  Mark Twain

                                  J 1 Reply Last reply
                                  0
                                  • J 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

                                    S Offline
                                    S Offline
                                    Sandeep Mewara
                                    wrote on last edited by
                                    #26

                                    Jeremy Falcon wrote:

                                    Anyone else agree this is fundamentally broken?

                                    Yes. For experienced folks, just a problem solving should not be the one to decide. It could also be an off day not just unable to answer exactly as the interviewer is expecting.

                                    Latest CodeProject post: Data Visualization - Insights with Matplotlib To read all my blog posts, visit: Learn by Insight...

                                    1 Reply Last reply
                                    0
                                    • J 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

                                      F Offline
                                      F Offline
                                      F ES Sitecore
                                      wrote on last edited by
                                      #27

                                      To be fair, putting arbitrary things at the bottom of the pile is a pretty important task for companies these days so it's no wonder they want to know you're good at it.

                                      J 1 Reply Last reply
                                      0
                                      • J 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

                                        M Offline
                                        M Offline
                                        Marc Clifton
                                        wrote on last edited by
                                        #28

                                        Jeremy Falcon wrote:

                                        Anyone else agree this is fundamentally broken?

                                        Yes. The answer that I gave some folks a couple years ago was "Please don't ask me questions I can google the answer for." There was a few seconds of silence. The question they asked me was something along the lines of "what's an abstract class?" Seriously? I've been programming for 40+ years and you ask me that??? Marc

                                        Latest Articles:
                                        Thread Safe Quantized Temporal Frame Ring Buffer

                                        J P M 3 Replies Last reply
                                        0
                                        • F F ES Sitecore

                                          To be fair, putting arbitrary things at the bottom of the pile is a pretty important task for companies these days so it's no wonder they want to know you're good at it.

                                          J Offline
                                          J Offline
                                          Jeremy Falcon
                                          wrote on last edited by
                                          #29

                                          True... I could see that for sorting say notifications on the frontend, but 9 times out of 10 you'd use a method like Array.protoype.sort() rather than roll your own. Point being, for most LOB applications... we don't have to re-invent the wheel.

                                          Jeremy Falcon

                                          J 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups