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 3 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.
  • D David ONeil

    Jeremy Falcon wrote:

    ...the quicker it becomes, but still... hard to work against the clock like that for something new...

    Grumpy Old Man mode (IE, Wise and Omniscient Programmer Mode): "Is this going to be a mission critical component of the software that will handle hundreds of millions to billions of values in an array, day in and day out? If not, buzz of - ANY solution I come up with for a twenty element array will be finished so shortly after the 'Enter' key is pressed with modern hardware that it doesn't matter. All that matters is getting on to the next thing. But then again, that probably isn't the right way to butter up a prospective job, although a good interviewer should recognize the truth to your statement and be much more inclined to hire you. :laugh:

    The forgotten roots of science | C++ Programming | DWinLib

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

    :thumbsup::thumbsup::thumbsup:

    Jeremy Falcon

    1 Reply Last reply
    0
    • J Jeremy Falcon

      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 Offline
      J Offline
      jsc42
      wrote on last edited by
      #50

      Jeremy Falcon wrote:

      we don't have to re-invent the wheel.

      That is probably the correct answer. Any good programmer will reuse (or, at least, get good ideas from) code that has been proven reliable rather than creating something new that may contain bugs.

      J 1 Reply Last reply
      0
      • H honey the codewitch

        I've had to hire for several firms. I don't think probing technical questions are even the best way to find good developers. Testing how people think is I think the best approach, but it's not always easy to come up with good questions for this. If I had my way, I'd be able to give each candidate a simple set of functional requirements and have them produce a small application (like notepad) then I'd look at the code. However, in practice, I've never had the opportunity to look at someone's coding style on demand like that. Whiteboarding is one thing, but it only gets you so far. When I do ask technical questions they are usually things like what is the practical difference between a linked list and a vector just to make sure they aren't totally wasting everyone's time but I can get that out of the way on the phone in a lot of cases. What I really look for though - and this puts a candidate on a shortlist for me is - do they love to code? Is it a passion? If the answer is yes, I can assume a fair number of important things about them, like that they will throw themselves at a new coding challenge rather than avoid them. The green ones are not always the best project managers, but they typically make solid coders who learn fast. Talent comes from passion, IMO. The nice thing about this, is you can tell. Do their eyes light up when they talk about code, or is it just a job to them? You can almost always tell when someone is really passionate about what they do. All that being said, I guess it should be obvious that I profoundly disagree with the techniques of interviewers you had. The questions they asked didn't find talent, and didn't really rate your ability. It seems like a poorly executed question attempting to get at the way that you think. And apparently it was complicated enough to trip up the interviewer themselves, which led them to passing over you. It sounds like they think an interview is an attempt to outsmart others and they succeeded in only outsmarting themselves. Even when I'm in your shoes I'm always the interviewer. The question in my mind when I approach a company is do *I* want to work for you? That has always served me well. You know what I think? I think you don't want to work for people like that anyway. I don't think they know how to find talent, so they probably don't appreciate the talent they have. If they did, one of them would have been interviewing you and what happened to you wouldn't have happened. So maybe they can't retain good people. It happens to a

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

        honey the codewitch wrote:

        Sorry for the long winded reply. I have a lot of feelings about the way the field hires.

        It's a great post, thanks for sharing. To your points I agree wholeheartedly. I find it's much better to ask them what they study at home and what tickles their fancy the most about tech. You can teach an algorithm to people, but you can't teach personality and drive. Granted, you do need a baseline to ensure the job can be done... but a solution based on a task that's akin to the actual work being done is better than algorithmic questions alone. Or at least ask some technical questions alongside the algorithm test and not just one and done on the algorithm by itself... make it a bonus question or something.

        Jeremy Falcon

        1 Reply Last reply
        0
        • J jsc42

          Jeremy Falcon wrote:

          we don't have to re-invent the wheel.

          That is probably the correct answer. Any good programmer will reuse (or, at least, get good ideas from) code that has been proven reliable rather than creating something new that may contain bugs.

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

          jsc42 wrote:

          rather than creating something new that may contain bugs.

          Exactly :thumbsup:

          Jeremy Falcon

          1 Reply Last reply
          0
          • D Daniel Pfeffer

            But internally, the splice() operation is performing an O(N) operation - moving all elements down by one position. Your solution is therefore O(N^2). If I were the interviewer, I would ask if you can see a problem with this solution, and then ask you for a more efficient (O(N)) solution.

            Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

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

            And while you're at, can you stop space and time and develop the first programming language used on Mars and feed that back to us? Then on the actual job... your coworker asks you... what's a box model again? How do you configure Webpack? How do I actually do any of the things my job requires? Well, at least I studied algorithms for a few weeks while interviewing. Phew. :rolleyes:

            Jeremy Falcon

            D 1 Reply Last reply
            0
            • F Fueled By Decaff

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

              I remember that from my C days. If someone asked me that in JavaScript though I'd have to take a step back end think about.... a lot. I miss a good XOR at times.

              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

                G Offline
                G Offline
                Gary R Wheeler
                wrote on last edited by
                #55

                XOR swap algorithm - Wikipedia[^]

                Software Zen: delete this;

                1 Reply Last reply
                0
                • J Johnny J

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

                  :laugh: :laugh: :laugh: :laugh:

                  Jeremy Falcon

                  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!

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #57

                    Doing it, "in place":

                    List a = new List( new int[] { 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0 } );

                    int count = a.RemoveAll( i => i== 0 );
                    a.AddRange( new int[ count ] );

                    It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

                    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
                      Super Lloyd
                      wrote on last edited by
                      #58

                      Interview I mostly bullshit, I totally agree! Often not done by the people who will work for you but by people who have no clue... with whimsical question either way... It highlights the following truism - being unprepared will guarantee you failure... - being well prepared will leave success to luck... To edge your luck a bit more one got also to work on social skill and self promotion! :p

                      A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                      J 1 Reply Last reply
                      0
                      • R RDM Jr

                        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!

                        M Offline
                        M Offline
                        Mike Winiberg
                        wrote on last edited by
                        #59

                        Hey, are you my alter ego? 8) I've just thought, maybe old programmers never die, they just become VBA devs... Like you, I started with FORTRAN; then Algol68, Algol60, Pascal, assembler, C, C++, Java, PHP and a few others; now HTML5/CSS/JS, SQL, Python and VBA (Access). By the time I reach 70, will I be reduced to Scratch? HA HA Bonk!

                        R M 2 Replies 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

                          V Offline
                          V Offline
                          V 0
                          wrote on last edited by
                          #60

                          Unfortunately life is a bit too much about getting the exact right answer, not on how you get there. :sigh: We've all been there. :-\

                          V.

                          J 1 Reply Last reply
                          0
                          • J Jeremy Falcon

                            And while you're at, can you stop space and time and develop the first programming language used on Mars and feed that back to us? Then on the actual job... your coworker asks you... what's a box model again? How do you configure Webpack? How do I actually do any of the things my job requires? Well, at least I studied algorithms for a few weeks while interviewing. Phew. :rolleyes:

                            Jeremy Falcon

                            D Offline
                            D Offline
                            Daniel Pfeffer
                            wrote on last edited by
                            #61

                            Jeremy Falcon wrote:

                            And while you're at, can you stop space and time and develop the first programming language used on Mars and feed that back to us?

                            Well, we already have the first programming language to be used on Jupiter ([JOVIAL](https://en.wikipedia.org/wiki/JOVIAL)) :-\

                            Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                            J 1 Reply Last reply
                            0
                            • M Mike Winiberg

                              Hey, are you my alter ego? 8) I've just thought, maybe old programmers never die, they just become VBA devs... Like you, I started with FORTRAN; then Algol68, Algol60, Pascal, assembler, C, C++, Java, PHP and a few others; now HTML5/CSS/JS, SQL, Python and VBA (Access). By the time I reach 70, will I be reduced to Scratch? HA HA Bonk!

                              R Offline
                              R Offline
                              RDM Jr
                              wrote on last edited by
                              #62

                              It does appear we have a lot of things in common. The first real life project I was on straight out of college I used Cobol on a IV-Phase mini, Fortran, Cobol and Assembler on an Interdata 8/32, and Fortran, Cobol, PL/I, RPG and Assembler on an IBM 370/158 MVS system, and also wound up writing the production JCL. Since then it's been Fortran on a Banyan network, Fortran and C under Ultrix on microVAXen communicating with Fortran on Windows PCs, then C on Xenix, SCO Unix, and finally Linux, to my hopefully final job with VB/Windows using SQL on an Access database, plus a lot of Excel VBA over the last 10 years or so. Now I've started playing around with 3d resin printing, Arduinos and Pi's in my spare time so I won't be too bored in retirement; also taking classes in electronics, microprocessors, etc, at the local community college since I can audit them tuition free now that I'm over 60.

                              M 1 Reply Last reply
                              0
                              • R RDM Jr

                                It does appear we have a lot of things in common. The first real life project I was on straight out of college I used Cobol on a IV-Phase mini, Fortran, Cobol and Assembler on an Interdata 8/32, and Fortran, Cobol, PL/I, RPG and Assembler on an IBM 370/158 MVS system, and also wound up writing the production JCL. Since then it's been Fortran on a Banyan network, Fortran and C under Ultrix on microVAXen communicating with Fortran on Windows PCs, then C on Xenix, SCO Unix, and finally Linux, to my hopefully final job with VB/Windows using SQL on an Access database, plus a lot of Excel VBA over the last 10 years or so. Now I've started playing around with 3d resin printing, Arduinos and Pi's in my spare time so I won't be too bored in retirement; also taking classes in electronics, microprocessors, etc, at the local community college since I can audit them tuition free now that I'm over 60.

                                M Offline
                                M Offline
                                Mike Winiberg
                                wrote on last edited by
                                #63

                                I'd forgotten about SCO Xenix/Unix: Believe it or not, the first multi-user reservation system I developed for a shipping/airline operator was written in dBase II running on Xenix with multiplexed Wyse terminals running over AC15 lines between sites. Did a lot if stuff in dBase at one time, it really was revolutionary in the early days of micros. Likewise T/Maker a predecessor to modern day spreadsheets. I may be an old git, but I've grown up with and used many of the significant developments in computing in the last 50 years and it has been an incredible (if not particularly well paid) journey. 8)

                                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
                                  Member 14174460
                                  wrote on last edited by
                                  #64

                                  Surely the best correct answer is to use std::stable_partition std::stable_partition( v.begin(), v.end(), [](int n){return n != 0;}); Its an excellent question because it shows you know how to use and won't rewrite standard code.

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    Doing it, "in place":

                                    List a = new List( new int[] { 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0 } );

                                    int count = a.RemoveAll( i => i== 0 );
                                    a.AddRange( new int[ count ] );

                                    It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

                                    J Offline
                                    J Offline
                                    jsc42
                                    wrote on last edited by
                                    #65

                                    This just occurred to me ... JavaScript's Array.sort enables you to use a function to say how sorting is done. All that is needed is a simple function to treat 0 as bigger than non-0.

                                    var data = [ 1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0 ];
                                    var sorted = data.sort( (a, b) => a == 0 ? 1 : (b == 0 ? -1 : 0) ); // First attempt
                                    var sorted = data.sort( (a, b) => a ? (b ? 0 : -1 ) : 1 ); // Exploits 0 == false, non-zero == true
                                    alert(sorted);

                                    L 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

                                      Sander RosselS Offline
                                      Sander RosselS Offline
                                      Sander Rossel
                                      wrote on last edited by
                                      #66

                                      I once worked for a company where everyone was a developer (except for two people in administration). They had about 30 people. This was from 2014 to about 2017 (just saying, because you may get the idea I'm talking late 90's early 00's). Before I got to work there I got a questionnaire with questions like "what's the next number/figure in the sequence?", "what happens to a candle and a drop of mercury in an elevator that's going down at a certain speed?"(???) something with a sailboat and wind, one question where I had to make a basic HTML page, and two or three database design questions. I skipped the nonsense questions like the sailboat and mercury because I really don't know anything about sailing or friggin' mercury :confused: I somehow made a mistake in the database design, which was unfortunate. Anyway, I got the job and immediately noticed everyone's knowledge was stale. They were working on old languages and frameworks, two teams did EVERYTHING in Oracle (yes, EVERYTHING, if all you have is a hammer...), I got across JavaScript code that returned various types from the same 100+ lines function, despite everyone being an "Oracle expert" (they wrote their own Oracle management tool) I got some very strange looks when I asked about JOIN syntax and tracing, etc. The person who was in charge for keeping up with new technologies only shared the occasional Oracle update (he was in that everything Oracle team). The few good people all quit, save for one who has a family and makes good money there, although he once told me "my career is going backwards here, I'm currently doing Oracle and Delphi." I quit because my team was extremely toxic due to some people being stressed out because they couldn't keep up. I really don't know what their questionnaire was testing, but it wasn't quality in any way.

                                      Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

                                      M J 2 Replies 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
                                        megaadam
                                        wrote on last edited by
                                        #67

                                        Some programming interviews are bad. Others are good. Let me flip the question on you: How would you interview a candidate?

                                        "If we don't change direction, we'll end up where we're going"

                                        J 1 Reply Last reply
                                        0
                                        • Sander RosselS Sander Rossel

                                          I once worked for a company where everyone was a developer (except for two people in administration). They had about 30 people. This was from 2014 to about 2017 (just saying, because you may get the idea I'm talking late 90's early 00's). Before I got to work there I got a questionnaire with questions like "what's the next number/figure in the sequence?", "what happens to a candle and a drop of mercury in an elevator that's going down at a certain speed?"(???) something with a sailboat and wind, one question where I had to make a basic HTML page, and two or three database design questions. I skipped the nonsense questions like the sailboat and mercury because I really don't know anything about sailing or friggin' mercury :confused: I somehow made a mistake in the database design, which was unfortunate. Anyway, I got the job and immediately noticed everyone's knowledge was stale. They were working on old languages and frameworks, two teams did EVERYTHING in Oracle (yes, EVERYTHING, if all you have is a hammer...), I got across JavaScript code that returned various types from the same 100+ lines function, despite everyone being an "Oracle expert" (they wrote their own Oracle management tool) I got some very strange looks when I asked about JOIN syntax and tracing, etc. The person who was in charge for keeping up with new technologies only shared the occasional Oracle update (he was in that everything Oracle team). The few good people all quit, save for one who has a family and makes good money there, although he once told me "my career is going backwards here, I'm currently doing Oracle and Delphi." I quit because my team was extremely toxic due to some people being stressed out because they couldn't keep up. I really don't know what their questionnaire was testing, but it wasn't quality in any way.

                                          Best, Sander sanderrossel.com Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

                                          M Offline
                                          M Offline
                                          megaadam
                                          wrote on last edited by
                                          #68

                                          Well the interview situation is a pretty good opportunity for you to interview them as well, so...

                                          "If we don't change direction, we'll end up where we're going"

                                          Sander RosselS 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