DEV Community

Discussion on: How to lose a Job in 10 minutes

Collapse
 
fnh profile image
Fabian Holzer • Edited

Well, interviews are always stressful situations, so don't beat yourself up about it.

But one remark: try to resist showing off too much technical cleverness. Two reasons for that: first of all, you risk getting lost in unimportant technical details (what was the exact signature of a reducer function again?) rather than acutally solve the problem. Also you might also raise suspicion that you value complexity over simplicity.

Personally I think the best interview preparation is having a real person in the room (which doesn't need to be technical at all) to which you talk. Mentally walking through an interview on paper or in a preparation book is not the real deal. It costs a little bit more effort, but is worth it. The second best to that is rubber ducking. But by any means: talk out loud, even if you are alone in your room.

All the best for your next interview (with or without whiteboard)

P.S. I could not help it, and came up with this alternative solution to the problem

Collapse
 
andreaspizsa profile image
Andreas Pizsa

Love your solution, Fabian; short, precise, efficient, readable & understanding the actual problem over having to show off reduce :)

This might be for you:
goodgamestudios.com/careers/jobs/h...

Collapse
 
andreaspizsa profile image
Andreas Pizsa

Here’s my take based on anagramNormalized (SCNR ;) )

function anagramNormalized(str) {
    return str.toLocaleLowerCase().split("").sort().join();
}

function groupBy(array, fn) {
    return array.reduce((result, word) => {
        const group = fn(word)
        const target = result[group] || []
        target.push(word)
        result[group] = target 
        return result
    }, {})
}

const list = ['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris'];

Object.values(groupByAnagram(list, anagramNormalized))
Thread Thread
 
albinotonnina profile image
Albino Tonnina

Thanks both of you!
Your solution I'm afraid doesn't solve the problem though!
It's important that the letters rotate one by one, sorting them would create false positives.

So London and Donlon would go in the same array but not DnnooL!

Also using reduce on an array is not showing off, come on, it's using a legitimate method of the array object, what's wrong with it :)

Thread Thread
 
andreaspizsa profile image
Andreas Pizsa

Ah, you’re right, I missed that requirement.

Nothing inherently wrong with reduce – I’ve used it in my solution ;)

But back to whiteboard interviews:

I've seen dev interviews from both sides of the table. Currently I manage a team of developers and as such I also hire people; we conduct interviews over video calls, and I ask candidates to take an actual coding challenge.

You might be surprised at how many people with "impressive" resumes apply for senior dev positions and can not explain or let alone code the simplest thing. And I mean the simplest thing, like sorting an array.

So, I like my whiteboard interviews because it helps me identify the strong candidates that we then hire to build a great team.

Thread Thread
 
albinotonnina profile image
Albino Tonnina • Edited

Hi Andreas!
I cannot surely disagree with you.

With this article I just explored a thought, a little doubt about this process: what is the actual skill that is being tested during a whiteboard interview? We know that observing a candidate during a whiteboard interview gives us insights about both their communication and their technical skills.
My hypothesis is that the particular "sub-skill" of communicating effectively under stressful circumstances such as an interview is a must-have if a candidate wants to pass this test.
This sub-skill though may tell little about the talent of the candidate, unless you are looking for someone that needs to have that of course.
And the lack of it though could overshadow any other skill they may have, maybe jeopardising the entire interview.
In conclusion what I would say is that people should do practice for this test.
If you're not a natural, practice is the way to go. Problem solved! ;)

Thread Thread
 
andreaspizsa profile image
Andreas Pizsa

In conclusion what I would say is that people should do practice for this test.

I agree and I appreciate your pro-active approach.

Keep in mind that failing this interview because of your lack of this one skill didn't get you the job you wanted and applied for. (I’m not saying this to criticize you)

Great candidates master this skill and at the same time are great developers as well. These are the ones everyone is looking for; and they are your competition.

Taking the proactive route of acquiring this skill will take you a lot further than blaming employers for doing whiteboard interviews; Kudos to you!

Thread Thread
 
juropolacko profile image
Juraj Polačko

Can someone please elaborate on why the solution with sorting string literals to be compared and then finding out if they are same (case insensitively) would not be sufficient? How does it not meet the requirements?

I understand that the point of this post is elsewhere but just not to wrap my head around it anymore.

Thank you

Thread Thread
 
fnh profile image
Fabian Holzer

Well, the solution matches the provided test case, but the test suite obviously was not extensive enough to test for all edge cases. Poof provided in his reply the hint

So London and Donlon would go in the same array but not DnnooL

It also was in the "interview" part of the article:

First question, do the letters just ‘rotate’ or they can be randomly mixed up?
Larry (to protect the privacy of the interviewers, I changed their name into a fancy one): Just rotate. First letter goes last

So comparing by the anagram builds up groups of the wrong equivalence class. To use the phrasing of Poofs article, it is "randomly mixing".

But the definition of "just rotate", as I understood it after the new test case, that DnnooL is not in the same equivalence class as London, is to be case insentively the same string as one element of the set that you get when you split the string at any index, swap the parts and concatenate again.

Albeit, I still stand by the general structure of the solution I proposed, which doesn't need reduce at all. Just swap the predicate isAnagram with isRotation, e.g.

function range(n) {
  return Array.from(Array(n).keys());
}

function allRotations(str) {
  return range(str.length)
    .map(index => [str.substring(index), str.substring(0, index)])
    .map(array => array.join("").toLocaleLowerCase());
}

function isRotation(a, b) {
  return allRotations(a).includes(b.toLocaleLowerCase());
}