News for hackers. Stuff that matters.
Re:Ask HN: What are your favorite code problems to give whil... by istvan__ on Friday June 12, 2015 @04:49PM (#9708448)
This is a great topic.

I like to split my interview to the following steps:

- introduction, small talk about the company or the candidate - level 1 write a function that flips a bit that is represented as a single digit integer: (0 -> 1, 1 -> 0) flip two variables (int) without a third one: (a,b -> b,a)

- level 2 what is the runtime complexity of a nested loop (assuming n == m) lease write a function that returns the list of numbers (in a string representation) that are permutation of N digits, where digits are 0..9. (1 -> 0..9, 2 -> 00 01....98 99 etc.) please explain recursion

- level 3 99% of the candidates do not make it to here I guess I should just make them flip that binary tree over the phone. :)

This is basics I think, so most of the software engineers should be able to solve these, even with a little hint.

On the top of these artificial tasks I usually ask them what is the biggest system they contributed code to, what was the contribution. What tools are they using. What is the favorite language and why. How do you to performance profiling for your code. What was the last problem that you solved in production, what was the problem and what is the solution.

And few others.

Re:Ask HN: What are your favorite code problems to give whil... by siscia on Saturday June 13, 2015 @06:31AM (#9710561)
How do you flip two variable without a third one ?
Re:Ask HN: What are your favorite code problems to give whil... by pdiddy on Saturday June 13, 2015 @08:36AM (#9710816)
Another way is to just use subtraction:

  x = x + y
  y = x - y
  x = x - y
I originally learned about this while preparing for some interviews.

The funny thing, I find, is that in Python you can simply do this:

  x, y = 5, 10
  x, y = y, x
I was asked this question in an interview and I responded that you can do this. His response: "Python is weird."
Re:Ask HN: What are your favorite code problems to give whil... by sllabres on Saturday June 13, 2015 @07:29AM (#9710703)
search XOR (X=X XOR Y; Y=X XOR Y; X=X XOR Y)
Re:Ask HN: What are your favorite code problems to give whil... by istvan__ on Friday June 12, 2015 @07:35PM (#9709202)
Sorry for the terrible spelling, I was in a rush.
Re:Ask HN: What are your favorite code problems to give whil... by MalcolmDiggs on Friday June 12, 2015 @06:11PM (#9708881)
I like to give some broken code and ask them to fix it...or give a Class that's missing a function or two and ask them to fill in what seems to be missing.

I tend to like those types of problems more than the "blank page" kind...I've found it to be a closer approximation of the everyday tasks they'll be encountering on the job.

Re:Ask HN: What are your favorite code problems to give whil... by panorama on Saturday June 13, 2015 @04:54AM (#9710391)
This is my favorite as well. Sure you'll be joining to write code from scratch, but day-to-day, you'll most likely be reviewing other people's code, hunting down bugs in other people's code, and so forth.

I'm a huge fan of "What can you fix or improve upon in this given code snippet?"

Re:Ask HN: What are your favorite code problems to give whil... by hoare on Friday June 12, 2015 @03:15PM (#9707960)
i guess if i say invert a binary tree i will be hunted down?:D
Re:Ask HN: What are your favorite code problems to give whil... by yankoff on Friday June 12, 2015 @03:22PM (#9708009)
a good thing is that now probably everybody knows how to solve it ;)
Re:Ask HN: What are your favorite code problems to give whil... by cweagans on Friday June 12, 2015 @06:38PM (#9708999)
The kind that they can solve at a computer with a real code editor.
Re:Ask HN: What are your favorite code problems to give whil... by kwc98 on Saturday June 13, 2015 @07:53AM (#9710743)
I like to describe a problem that we are currently experiencing or one that we had in the past to see the troubleshooting logic in play. I love explaining something that is not quite optimal in production and see if this person could help.