Live data from Hacker News

How to win the coding interview

blog.devmastery.com

231–240 of 305 posts

Re: How to win the coding interview

#231

> Who on Earth writes code on a whiteboard? Like, seriously You know, professionals do this. Anyone who value time and quality. Hipsters may find it weird, but, well, they have decades to learn before they'll become professionals.

I have been an engineer for 14 years and writing software full-time for 8 or them. I have never written code on a whiteboard outside of an interview. I have drawn circuits, flow diagrams, UI wireframes, ERDs, memory layouts, and so on. I don't have my own whiteboard now and it drives me crazy. I have never had a need to write actual code on a whiteboard. Neither has anyone I have ever worked with.

Flowcharts are code. Pseudocode is a code.

Re: How to win the coding interview

#232
> I guarantee you this, there will come a time when we are banging our heads against a problem and there is a deadline looming and we’re tired and people are pissed at us and money and jobs and reputations are all on the line. When that time comes, we’re going to have to get into a boardroom, hop on a whiteboard, and figure things out. Fast.

False, that has never happened in decades of work in my experience. All "breakthroughs" I've had came to me in the shower or other solitary place. For most people, creativity does not spring from a gun to your head in a crowded room. The rest of the piece falls apart from there.

Re: How to win the coding interview

#233
Oh my gods! This is what passes for an answer to "identify a palindrome"? All of that?? 59 lines to ensure a string is equal to itself reversed (hint-hint, nudge-nudge)? Why?

  'use strict'; // avoid ambiguity and sloppy errors

  /**
 * Tests whether or not a given string is a Palindrome
 * @param {string} stringToTest - the string to test.
 */

  function isPalindrome(stringToTest) {
    var start = 0,
        end;

    // make sure we have a string.
    if (typeof stringToTest !== "string") {
        // throw if we didn't get a string
        throw new TypeError("isPalindrome() expected a string, but got " +
            Object.prototype.toString.call(stringToTest) + " instead!");
    }

    // normalize string by lowercasing and removing non-word characters
    stringToTest = stringToTest
        .toLowerCase()
        .replace(/[^a-z0–9]/ig, '');

    if (stringToTest.length === 0) {
        // warn if we have no valid characters to test
        console.log("No valid characters to test, treated as empty string" +
            "\nStack: \n" + new Error().stack);
        return true; // an empty string is a palindrome.
    }

    end = stringToTest.length - 1;
    // Compare characters from outside in. Stop when we get to the middle.
    while (start 
}

  // tests (should be in a separate file using a test framework)
  console.log(isPalindrome("something that is not a palindrome") + " = false");
  console.log(isPalindrome("something that is \n not a palindrome") + " = false");
  console.log(isPalindrome("race \n car") + " = true");
  console.log(isPalindrome("") + " = true + warn");
  console.log(isPalindrome("  ") + " = true + warn");
  console.log(isPalindrome("1221") + " = true");
  console.log(isPalindrome("0") + " = true");
  console.log(isPalindrome("racecar") + " = true");
  console.log(isPalindrome("No 'x' in Nixon!") + " = true");
  console.log(isPalindrome("~~!~!~") + " = true + warn");
  console.log(isPalindrome("Momsie") + " = false");
  console.log(isPalindrome(12)); // blow up
  console.log(isPalindrome(undefined)); // blow up
  console.log(isPalindrome(null)); // blow up
Godsdammit- I'm pretty sure I'm not missing the point here. That is a ridiculous amount of overengineering, it should not be accepted as an answer to such a simple question, under any circumstances.

Re: How to win the coding interview

#235
> Before I start though, I have to say, if a company is going to hire a developer based solely and entirely on a piece of code the developer wrote in an interview, you probably don’t want to work there.

This is something I read many times when talking about interviews, and it makes no sense. Either there is a nonzero chance to be more successful in the interview if you perform good in coding exercises, or not. If the former, then there was at least one person in the history of mankind who was hired depending solely on the coding.

Re: How to win the coding interview

#237
post #143
post #32

> I'm not actually testing how well you write code on a whiteboard. I’m looking for something else Even if you believe so, it's more likely than not you're not actually doing that. You WILL judge how well someone write code on a whiteboard. I've done that too, and it's surprisingly easy not to notice. You can't stop yourself from judging, maybe you can realize that your snap judgement mean jackshit and don't make dec…

>As someone who can't figure out if (9+1 === 10) is true or not under interview As someone who has probably the same problem, any ideas how to land a better job? Those typically involve a lot of coding while someone breathes down your neck.

At the very least, you can always talk through your thought process. "I can't remember if the order of operations is..."

Re: How to win the coding interview

#238
post #66
post #36

I'm tired of companies asking me to code at their interviews. I have 10 years experience with references. I have code that I've built, deployed to production still running today. I have cultivated my own clients, gathered requirements and built something that delivers business value. Instead of a coding interview, I'll make a counter offer. Why not hire me on a 1 week contract to come and do some real world work. Wor…

>Instead of a coding interview, I'll make a counter offer. Why not hire me on a 1 week contract to come and do some real world work. Work that is small enough to be done in 1 week and big enough to deliver some value. Except now I have to jump through hoops with HR (let's just assume they'd be OK with this, which they almost certainly won't), get the contract in place, work with IT to get your environment set up, and…

>Except now I have to jump through hoops with HR (let's just assume they'd be OK with this, which they almost certainly won't), get the contract in place, work with IT to get your environment set up, and bring you up to speed (so really I may get one full day of actual work)... just to realize that I don't want to hire you.

There are two major reveals in that sentence. One, HR rules your hiring practice and therefore you and your department, and you just advise them. Two, your company is so soul-suckingly bureaucratic, I couldn't imagine a good, creative, problem solving developer would ever want to work there. Both are red flags.

Re: How to win the coding interview

#239

Earlier quoted context omitted.

I've had students that did this. It's a real pain to read code like that, and the 2nd time they handed it in, it was an automatic fail. Comments explain assumptions, and often "the why", never "the what" unless it's obscure because of optimizations.

I have had a teacher that said you needed to comment every single line because that's how code is written in the real world. I told him he was wrong and argued with him on more than one occasion. In the end, I just did it his way because there wasn't a good alternative.

> In the end, I just did it his way because there wasn't a good alternative.

Ironically, that is quite a bit like the real world.

Re: How to win the coding interview

#240

>Write the most efficient function you can that determines wether a given string is a palindrome. >When I offer a challenge like this in an interview, the first thing I’m looking for is wether or not you ask me any questions > / * Tests wether or not a given string is a Palindrome * @param {string} stringToTest - the string to test. */ Don't take coding advice for someone who can't spell whether.

Apparently wether is a castrated male sheep or a castrated male goat. Just saying.:D I have learnt something new today !

Similarly, "payed" is something you do on a ship. The hazards of relying on spellcheck.
Post reply on HN