re: How to lose a Job in 10 minutes VIEW POST

re: Here’s my take based on anagramNormalized (SCNR ;) ) function anagramNormalized(str) { return str.toLocaleLowerCase().split("").sort().join(...

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 :)

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.

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! ;)

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!

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

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());

code of conduct - report abuse