I agree, its not that hard, but that's all the more reason to avoid giving attitude about the question. Answer it quickly and move on. If you can't answer it quickly, maybe it _is_ that complex.
A lot of interviewers have a short time window in which to conduct their 1-on-1. Sometimes they ask easy questions for a reason.
Often, I start with a soft ball that I intend on building on - turn a linked list into a doubly linked list; a circular list; can you improve the lookup time; can you make it generic; what are the space constraints; what are the time constraints.
And if they can't answer the simple question, we just leave it at that.
A simple question can easily be built upon. "I'd Google it" can not.
There are many people for whom this is complex, you're assuming a foundation that not everyone has. There are also many people for whom nothing is complex, they assume they can understand everything, while they don't currently, they assume they'll be able to learn it without issue.
Dealing with new starts who are straight out of education is often like reading posts from 4chan.org/b, at first you don't know if they're joking.
It's not all doom and gloom, occasional I'm pleasantly surprised by the calibre of those beginning their career/hobby, but this is the exception.
Few questions I usually ask:
- How can you make sure that your Java application runs on the server not only on your laptop? (I take any answers: containers, single JAR, etc.)
- What is printed out
def add_list(val, list=[]):
list.append(val)
return list
print add_list(10)print add_list(20)
print add_list(123,[])
- Explain recursion
Funny to see how a non-trivial amount of programmers fail to answer these questions.
...unless you need them for lock-free programming. There was a nice C++ talk by Herb Sutter on that, with the apt title "Juggling Razor Blades". That pretty much says it all.
From a practical standpoint, the question "what is a linked list good for?" really might be more interesting. Does anyone know of potential use cases besides kernel design, lock free programming or Clojure-style immutable datastructures? I'd guess CPU caches to have erradicated most of them...
1. Write a function that determines if a number is prime. If they didn't know what a prime number was, we would tell them.
2. A simple problem that required designing a database schema and sql query that involved a left outer join.
There were a lot of developers who couldn't do it.
On the other hand, there was one developer who was just learning c#, who had spent most of his time doing VB.net, couldn't answer a lot of the technical questions but we could tell by his thought process and how he explained real world problems he solved that he would be a great asset to the company. We fought for him over more "senior" developers.
When I have a chance to hire again, I'm going to fight to get him -- even though he sucks at interviewing and i might have to do a little convincing.
Did you also give them an algorithm to implement or was a brute force method good enough?
1st level optimization: skip even numbers.
2nd level optimization that I was the only person to get when I had to interview for the company: loop starting at 2, and go the square root of the argument.
That depends on the language. If you're using something without pointers or references it's quite hard.
They all use them internally, but don't tend to make them available to the programmer (usually because they aren't needed).
Behind the scene, yes, every Python variable is a reference to an object. It's not addressable, however, and in the case of immutable objects (like strings), you can't modify the underlying object and keep all references pointed at that updated object.
[0]: https://github.com/buserror/rf_bridge/blob/master/src/rf_bri...