5 Unusual Test Questions I Got While Interviewing for Web Dev Roles

jen chan on December 28, 2017

Poor Mister Unicorn Update: I changed the title from “5 Questions Companies Ask To Filter For CS Degree Holders” to the current one as the ti... [Read Full]
 

"don’t look up documentation online" - when you hear this, run.

 

Agreed. It's fortunate that I've never run into this myself, but my immediate response to that sort of thing is "Do you expect your employees to not utilize documentation while at work?"

It's absolutely absurd.

 

My gut feeling -giving them the greatest benefit of the doubt- is that they think you've used certain methods so much you'll remember...

 

Unfortunately I’ve had this a couple times. (Sits in room flicking pencil)

 

Once saw someone tweet that they'd respond to such a question saying "that's an interesting problem, do you come across this often here?"

You may not want to try it at home ;)

 
 

The last one is actually a fairly plain regex problem: why should anyone use Arrays or OOP here? The latter at best if they want you to implement a new String method, ok, but meh...

 

I imagine you meant Q7 by the "last" question. I'm curious how you'd solve that with regex; I didn't suggest it because I don't know any better. I would struggle to remember character patterns.

 

Of course I meant the last one.

It is a pretty trivial task, to be fair:

String.prototype.count=function(elem, caseInsensitive = true){return (this.match(new RegExp(elem, `g${caseInsensitive ? "i" : ""}`))||[]).length;}
"Pippi".count('p'); //returns 3
"Pippi".count('p', false); //returns 2

On request I can offer code in Python, Ruby, Crystal and possibly something more.

Oh, and Pippi is my cat <3

Thanks for illustrating that. It’s a new way of looking at it. And yes, in hindsight that question is not unusual.

I got that q twice in no-documentation situations so i just iterated through a string and return the number of truthy values. Not as rigorous or pure, but gets the job done.

I assume you mean "situations in which I could not google" or the like; it might have been more efficient then to filter, at least space wise, instead of mapping a string and then running through an extra item of length n to count again.

Better yet, a reduce approach, to keep it in n time.

I would still think that a RegExp-based approach would have an edge in terms of performances, as long as you use NodeJs which has some really impressive regex engine under the hood, but I am too busy (or lazy) to build a jsperf about it right now.

If you fancy some practice with this kind of stuff, come and join us on CodeWars - it is cool and we have a rather good community.

Edit: oh, cool, this place support the git-flavored markdown! Edited the snippet above!

Yes, I meant what you meant, but said "no documentation" to include situations where interviewers would throw you an O'reilly book or pdf for reference, but insist you can't code with internet.

Does every char make a difference? I read somewhere that for loops are still faster than forEach. Is coding an exercise like copywriting for sentence refinement? For me the thing got me into coding were the sexy results (coming from a background in video, things like animation didn't need to be rendered ahead of time as a huge file, if they could be executed as code, but of course, you could heat up your computer and slow down the browser etc ). But I can tell bad performance would impact quality and users would bounce away, so these things matter.

I agree with using the map and reduce functions. It makes a lot of sense. I only just got used to using map without errors!

At the risk of looking stupid in a euler-project style community I feel should ready myself by reading the aforementioned stack of books in my post, which have just arrived from Manning. I'm particularly excited about grokking algorithms, as a visual learner. I never learned code by reading books, but I realize there's some persnickety things you just don't learn by doing, then doing exercises after reading. It's a very different way of learning.

Also, is codewars for-pay? Must you be part of a "clan"? God I don't like that term.

I am not sure why (HR) people decide to structure interviews that way; I was discussing with other devs recently and it makes no sense at all: ok, if you don't know what's the event loop, you can't explain how promises work or the like, then it tells me that you are not a great JS dev. But when I interviewed candidates I never expected them to quote MDN verbatim, much less I would care to see their merely mnemonically acquired knowledge of APIs or CSS properties.

Not sure about which user case you are referring to, but I doubt a for loop can outperform a .forEach(), as you need to declare a variable to iterate through it in the same way. Maybe some engine has some strong optimization, but I would guess that it is because the latter works only for array, which would imply that you first would have to turn the string into an array of characters (which technically was already how is more or less represented at a lower level, but I digress: still computationally expensive!), store the extra value at the cost of extra space and then loop though it with our beloved .forEach() (again, a .map() would be more convenient most of the time and we all love the idea of going functional whenever it is possible, don't we?).

Let me suggest you a small exercise to flex your functional muscles, then: might you replicate the behaviour of map() and .filter() using only the .reduce() method? And could you do so in order to be even more performing?

At the risk of looking (even more) rude and blunt, I think that is BS: books should be the companion of a practical training, not the other way around. You seem to have a decent grasp of core concepts, but what strikes me is that you apparently lacked practice in this kind of problems. Would you think you would become a great martial artist, ballerina or surgeon just reading books? And while I tend to disagree also with the fad of classifying/labelling people in things like "visual learner", assuming that actually works for you, go on YT, watch some video like the one from hacker-rank which in less than 10 mins can visually show how a quick sort or a BFS or an A* or whatever other algo works. But only after you hit the nose against the hard wall of a problem you cannot solve. Yet.

CodeWars is free to you (the pay option is to support the devs in exchange for a few extra stats and info on your profile); the "clan" term is just to follow the ninja/samurai gimmick of the site, same as ranking the katas by belts.

god, let me read! I like it! 🤣

I think even before I solve problems I ought to understand what needs to be solved 🤷🏻‍♀️

The background knowledge is like a toolkit, you don’t know what you can use if you don’t know even know about it. I have a feeling you’re overestimating the amount of “core” I know since the first time I heard of sorting algo or binary tree or o(n) was in interviews.

I agree I lack practice. I just got my adhd under control so it’s been wonderful for learning and doing. Back when I didn’t, I could never read top to bottom let alone hold onto thoughts.

Feel free to read, but in due time you need to build automatism like a professional athlete or chess-player.

I don't think I am over-estimating much, I see you have plenty of shortcomings (this discussion came from one of them, didn't it?), but I also see that you have a good understanding of a lot of stuff and that you practiced with commitment.

That is more than enough in my book, so I would still recommend to practice more as a first step; the drive to read and do more comes better after you see implementations of such a knowledge.

 

Although I agree these interview questions are absurd, there is a good amount of merit to seeing peoples responses. I've been to interviews where I didn't answer a single question right and still got the job. I approached each question as a collaborative effort with the interviewers. "Don't look up documentation online" (if it is a good interviewer) really means "Ask me for help".

I will add though, if you're given a task and a set amount of time with no internet/resources while they leave the room. Walk out. Development should never be in a vacuum.

 

In hindsight I think the hamburger sandwich menu question and the final 2 (number 5 and 6) aren't unusual to test on devs, but seeing how they tackle it without other prompts would definitely be interesting. (Under pressure my tendency is always to write more code than i need-_-) I also do like the ask-for-help thing, if they make themselves available for that.

code of conduct - report abuse