Live data from Hacker News

How to win the coding interview

blog.devmastery.com

71–80 of 305 posts

Re: How to win the coding interview

#71
post #18

On the flip side of things, I might prefer to see a candidate come up with something like this as first stab rather than that 35-line mammoth of an isPalindrome() function in the article. function isPalindrome(str) { return (str.split("").reverse()).join("") == str; }

To start conversation in OCaml,

let is_palindrome str = str = String.rev str ;;

(function is_palindrome will return true or false for input str )

Re: How to win the coding interview

#72
post #50

Earlier quoted context omitted.

Some reasons against a 1 week working interview: * It can take up to a week just to get someone ramped up with access to things in many environments (setting up accounts, configuring dev environment, etc.) It's not free to create and disable a dev's access. * Most places I've seen aren't set up to ramp someone up in a week. I think Pivotal Labs gives people a try for 3 week contracts, and they have a culture of rampi…

You make a good point, but if I'm getting to pick my ideal work environment though, it's one where I can get ramped up and contributing meaningfully in a week.

If I'm working in my ideal work environment, the problem we are trying to solve is too complex to understand fully within a week.

Re: How to win the coding interview

#74
post #54

Why regexes combined with the pre-processing? First, it's not so clear in what sense "efficient" is actually a real requirement if this is a model answer. If the average input is very small then the cost of compiling/interpreting the regex is going to dominate any modest run-time improvement over even an extremely naive implementation. And if the inputs are very large then the probability of contradiction in the firs…

Regexes would not be a good way. Starting a pointer at the beginning and end and moving them toward each other is what I would suggest in an interview. If I was interviewing someone else, I'd also be impressed if they came up with the idea of sorting the string and counting characters (only at most one character could have at odd number of occurrences). Even though sorting and counting is nlogn and requires either st…

>I'd also be impressed if they came up with the idea of sorting the string and counting characters

While that method would identify if a string has the necessary attributes of a palindromic string it is not sufficient to prove that a string is a palindrome.

>This is the person judging the candidates on whether they are talented enough at computer science? Yikes.

Right, anyone reading the OP would probably be better served by Steve Yegge's posts[0, 1] on the subject.

[0] https://sites.google.com/site/steveyegge2/five-essential-pho...

[1] http://steve-yegge.blogspot.com/2008/03/get-that-job-at-goog...

Edit: Went back and actually read the code provided, they only use regex for a preprocessing step.

Re: How to win the coding interview

#75
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…

Most good candidates wouldn't put up with that situation (1 week contracting) - also, years of experience can vary drastically. I recently interviewed a candidate with over 15 years of experience, predominantly in the backend, yet he didn't really have much experience scaling systems. He checked out in all ways until we drilled down into scaling issues.

Re: How to win the coding interview

#76

Earlier quoted context omitted.

Yes. Unless you're not the only person we're looking at hiring. We're not going to pay 10 people for a week and hire just one. We'd rather we get a sample by seeing you do some work on a whiteboard, and make some cuts right then and there. In other words: yes, that's a better way for you to prove yourself. No, we don't have the resources for this approach.

You don't want to pay 10 people for a week. You want to pay one person at a time over a 10 week stretch. That way, you can evaluate each candidate independently and hire the best one. This is undoubtedly a better approach than doing a bunch of coding interviews, so you should have a strong incentive to make sure you have the resources for it. After all, you want to minimize the risk of hiring mediocre people and maxi…

I don't know where you work, but I have never had the luxury of 2.5+ months to get a position filled if we can help it (and it's silly to assume that the work required behind the scenes to get this all working would result in no gaps between candidates, so more than 2.5 months).

I also don't typically have the luxury of having great candidates in front of me who will wait multiple weeks to get into some weird one week eval (and they usually have a job already, so how are they going to get away for a week?). This is a time consuming and expensive proposition which would require buy in at multiple levels from multiple departments and would probably end up not working out so well.

Re: How to win the coding interview

#77
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…

This is the perfect and ideal process but unfortunately hard to scale.

Forget scale; I don't think it's practical for even one candidate.

Re: How to win the coding interview

#78
post #52

Earlier quoted context omitted.

What I've seen suggested elsewhere is having publicly viewable code on github or the like - that would effectively be your coding resume and evidence of your ability.

True but it is not that hard for someone to fake that if they really want to. That said, faking history in github likely takes enough technical ability that the person could probably do a decent job programming if they use their powers for good.

I wouldn't be surprised if there's a pre-baked script out there that clones a repo and rewrites all the commits with a different author and committer.

Re: How to win the coding interview

#79
post #4

Very interesting article, thanks for writing! I have but one, eh, comment: > Your code should be commented Sure.. but: > * @param {string} stringToTest - the string to test. > // make sure we have a string. > if (typeof stringToTest !== "string") { > > function isPalindrome(stringToTest) { > ... > // if we get here, it's a palindrome > return true; Do we really need to explain that stringToTest means string to test?…

And perhaps the interviewer should have been more explicit in their requirements. I have to admit I would never think to comment whiteboard code (and my production code would not contain comments like that).

Re: How to win the coding interview

#80
post #56

Earlier quoted context omitted.

Yes, I don't understand the suggestion for regexes as the correct and optimal way to detect palindromes. I hope this is not the expectation in general.

It is pretty ironic that palindromes cannot be recognised by regular languages.

Hah, yes. That's probably the simplest application of the pumping lemma I can think of.
Post reply on HN