I’m really getting feed up with people asking me dumb questions. I’m not a recent college graduate and don’t have quick-sort memorized. I’m also not a search engineer. So I’m not going to be able to impress you with the algorithm I develop in 5 minutes during our face-to-face interview on a white board.
I was on an interview this afternoon, and I was asked by a Java developer … something along the lines:
Giving the string ‘abcdedbfghijk’ find the position/index of the string ‘db’
Ok, great. Sure, simple. But kind of a waste of time and really doesn’t show you anything. I told him, I don’t know exact syntax but use a match function in your scripting language and it usually returns the index for you. I wrote something like this on the white board :
$ret = match ( 'db', $subject_str);
Ok, not exactly, but I talked through it. After the fact, here is the solution in PHP:
$subject = 'abcdedbfghijk'; $find = 'db'; $x = preg_match_all ( '/db/', $subject, $matches, PREG_OFFSET_CAPTURE) ; print_r ( $matches);
And well, it works :
[ ttys002 defiant.local:~ ] [ dpd ]> php interview.php Array (  => Array (  => Array (  => db  => 5 ) ) )
But I was asked … well, can you do that in Java ? I’m like uh … probably not. I’m sure Java has a string-match function in some class. But I’m not a Java developer. I’m pretty sure that he wanted me to write a loop doing character sub-string comparisons. But I told him that was a waste of time and really doesn’t prove anything.
I gave a correct solution – at least good enough for a white board. Albeit, didn’t have remotely correct syntax. But apparently that wasn’t good enough for this job.
This pretty much ended the interview. Feeling was pretty mutual – I should have walked out about 20 minutes earlier.