Re:Lessons from 3,000 technical interviews
by dsp1234 on Thursday December 29, 2016 @01:08PM
(#13278868)
Do you have an example which correctly solves the problem but takes too long?
Behold
var AGESORT = rows.bubblesort("AGE ASCENDING")
var AGESORT1 = rows.bubblesort("AGE DESCENDING")
var MALE = "None"
var MALE1 = "None"
for row in AGESORT
if row.isMale
MALE = row
break
for row in AGESORT1
if row.isMale
MALE1 = row
break
print "Min age: " + MALE
print "Max age: " + MALE1
Stuff like this is usually the result of thoughts like "Ok, I'll break this problem into two, then combine the pieces. First I'll find the minimum age, which is easy once I sort the rows. Done. Ok, now I can see I can slightly alter that code so that it finds the max age! Now, I just put the pieces of code together, and do a little code organization to put like with like. I"
Re:Lessons from 3,000 technical interviews
by sten on Thursday December 29, 2016 @01:19PM
(#13278932)
Good point.
Re:Lessons from 3,000 technical interviews
by timr on Thursday December 29, 2016 @12:21PM
(#13278535)
Which problem? The first one? Don't underestimate the badness of the average interviewee.
For the "find the min and max of a set" in particular, a lot of folks start out with terrible solutions.
Re:Lessons from 3,000 technical interviews
by sten on Thursday December 29, 2016 @01:02PM
(#13278827)
Well either I suppose. For the subset problem as you say a filter critera can be applied while looping through the collection. And that should be it. Now if the question was multiple criteria I could see the solution diverging rapidly. If the filter can be expressed as a rank we could sort the collection first and then binary search through it to find the boundaries. I suppose I'm just trying to imagine some way an interviewee may turn that into two loops, or three loops... more?
The only thing I can think of is something like the output rewriting an array on update over and over.