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 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
                            • M Marc Clifton

                              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 Offline
                              J Offline
                              Jeremy Falcon
                              wrote on last edited by
                              #30

                              Marc Clifton wrote:

                              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???

                              Ha ha ha ha ha ha. I laugh because I know developers who have asked a question like that way more than once. Interviewing is a bit of a skill unfortunately. It's not something that just naturally comes to people simply because they learn to program. Granted, it's important you are technical in one IMO, but you gotta learn the soft skills too.

                              Jeremy Falcon

                              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

                                F Offline
                                F Offline
                                Fueled By Decaff
                                wrote on last edited by
                                #31

                                There is an old trick from days when memory sizes were counted in bytes. (No I did not figure it out and had to be taught it.) Use three exclusive or operations. This will avoid the overflow issue of using add and subtract. For example:

                                a = 15
                                b = 5
                                a = a^b
                                b = b^a
                                a = a^b

                                J J 2 Replies Last reply
                                0
                                • M Marc Clifton

                                  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

                                  P Offline
                                  P Offline
                                  peterkmx
                                  wrote on last edited by
                                  #32

                                  Quote:

                                  Please don't ask me questions I can google the answer for

                                  :-) great line idd ...

                                  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

                                    P Offline
                                    P Offline
                                    peterkmx
                                    wrote on last edited by
                                    #33

                                    Suddenly I think about "ICT-competences modelling" as a few years ago I participated in a research project on higher ICT education. Indeed I think that most HR "still" do not pay attention to relevant aspects of a "programmer"-profile such as communication capabilities, team skills, problem solving, organizing the work, etc ...

                                    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
                                      Fueled By Decaff
                                      wrote on last edited by
                                      #34

                                      It is annoying when faced with something like this, but it is surprisingly common. In my opinion a programming test should be short, simple and should only be possible to be failed by someone who can not program - ideally you should be able to use it as a springboard for discussing programming techniques. A lot of people are not good at on the spot tests like this, so this type of interview gets a lot of false negatives. I guess Acelook can pass over good candidates, because they have a lot of candidates to choose from. Perhaps they use custom algorithms and need every programmer to be able to create them. One slight point though - your single loop solution will typically be slightly less efficient then the two loop solution, although it does seem clearer what your solution is doing. Addendum: So when does OG start at Acelook? :laugh:

                                      J 1 Reply Last reply
                                      0
                                      • J Jeremy Falcon

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

                                        Jeremy Falcon

                                        R Offline
                                        R Offline
                                        raddevus
                                        wrote on last edited by
                                        #35

                                        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

                                        J D M 3 Replies Last reply
                                        0
                                        • M Marc Clifton

                                          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

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

                                          Marc Clifton wrote:

                                          "what's an abstract class?"

                                          A lesson where you learn to paint like Mondrian?

                                          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