r/datascience • • Feb 15 '21

Job Search Please STOP asking Data Scientists about Leetcode questions meant for Software Engineers for job interviews

I've been working as a Data Scientist long enough to say that asking Leetcode questions for Data Scientists is completely disrespectful. This is both for both product and ML-based data scientists.

Something simple is fine, like hashmaps, two pointers, strings, some light algorithms etc. But graph theories, DFS with trees/dynamic programming has nothing to do with data analytics, ML fundamentals, statistical foundations, and data storytelling competence.

I really don't understand. When you have a wealth of ways to distinguish competent Data Scientists from juniors during interview pipeline (complicated SQL, pandas, data munging, visualization, ML training, building simulation code, etc.), why you'd rather choose questions like "how many moves do you need to get a Queen chess piece from this position to another on a chessboard" as a way of measuring how well a Data Scientist would perform analytics or ML training on the job. It really just feels like SWEs making fun of Data Scientists about how poor programmers we are.

Most companies don't pull crap like this, but for those who do, PLEASE STOP. Unless we received a BA or MA in computer science -- which majority if not most of us did not -- we won't be able to solve shit like this unless we cheat and look at answers directly on leetcode or geekforgeeks. And it's infuriating and embarrassing for us to sink to this kind of level to solve questions that aren't meant for us. I get that Data people need to know programming, but WE AREN'T SWEs, and DS is not SWE.

Edit: I'm getting a lot of replies saying that I suck at programming and I need to learn SWE fundamentals. I said over and over that I'm not against understanding foundations of SWE (hashmaps, runtime, pointers, optimized solutions vs brute force). These are important. But when you get into highly niched algorithm named after somebody where you need to do some complicated tricks or build a whole system that requires multiple functions, DFS-based dynamic programming, multiple inheritance methods all in 45 minutes that would unnerve even seasoned SWEs out of practice, that's when it becomes totally unreasonable, outside the realm of data science, and just disrespectful to what Data Scientists do on a daily basis. But that's the line I draw, and the overall question is: at what point do interview questions become unjustifiable and unrelated to the position at hand? I've spent years using pandas, scikit-learn, tableau, and complicated SQL for daily data tasks. Why is it that you can't test me on this stuff which occurs on day-to-day basis for majority of data scientists?

Edit Edit: Btw, shame on those of you just downvoting everything I'm saying without reading any of it (I can't even locate my own comments anymore). It's immature and completely ridiculous. I know it's the internet, but have some decency and respect for your interlocutors. You guys are all professionals right?

984 Upvotes

324 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Feb 16 '21

That's not true. What if I said solve the Jewels problem without any extra space? In other words, no hashmaps/lookup table? What would you do then

1

u/Kengaro Feb 17 '21 edited Feb 17 '21

You can post your code (below) on r/programminghorror and see what the ppl think of it...

def solution(jewels, stones):
    jewels = [ord(i) for i in sorted(jewels)]
    stones = [ord(i) for i in sorted(stones)]
    i = 0; j = 0; count = 0;
    while j < len(stones) and i < len(jewels):
        if stones[j] < jewels[i]:
            j+=1
        elif stones[j] == jewels[i]:
            count+=1
            j+=1
        elif stones[j] > jewels[i]:
            i+=1
    return count

What if I said solve the Jewels problem without any extra space? In other words, no hashmaps/lookup table? What would you do then

Than I'd say ok, I'll do it in C^^

That's not true

It is, explanation below:

The reason to use 2 pointers is so that you do not have to process a whole list to get a result which fullfills specific conditions and is created by combining 2 elements of that list. If you have to process the whole list there is no reason to do it.

You do use in total: 2 lists as inputs + 2 lists as intermediate data + 3 ints. I dunno where the heck you get the idea that this is no additional space, just coz you explicitlly declare a thing does not make it non-existant. You can also explicitlly create a hashmap. Using a hashmap would require to generate 2 lists as intermediate data + 1 int, meaning you use less!!!!!!! memory....

1

u/[deleted] Feb 17 '21 edited Feb 17 '21

"The reason to use 2 pointers is so that you do not have to process a whole list" - not really from what I'm seeing. Usually when you have these multiple sorted lists and need to traverse through them multiple pointers is one of the optimal solutions.

Here's a similar problem: https://www.geeksforgeeks.org/find-common-elements-three-sorted-arrays/ "we can find the common elements using a single loop and without extra space."

I was also asked during an interview recently at a Fang company to solve three sum problem without using any hash and using pointers and while loops alone for similar O(nlogn) solution. I don't think "I'll solve it in C" was the answer they were looking for.

But I'm happy to learn more about intermediate data. I'm not sure exactly what that is. Can you explain? I don't know what you mean by 3 ints either

1

u/Kengaro Feb 17 '21 edited Feb 17 '21

"The reason to use 2 pointers is so that you do not have to process a whole list"

I never wrote this, I wrote the thing below.... What do you think you have to do without the pointers for each case?

The reason to use 2 pointers is so that you do not have to process a whole list to get a result which fullfills specific conditions and is created by combining 2 elements of that list

What do you think the thing below does? How much memory is used at max when executing this function? How could you improve it?

jewels = [ord(i) for i in sorted(jewels)]

What I call intermediate data is data allocated during the function, that is not a real term tho. Roughly said, it is implicitly created memory.

i = 0; j = 0; count = 0;

^ these are ints, or Integers, i & j are what you call extra data in the context of the jewels & stones problem.

Here's a similar problem: https://www.geeksforgeeks.org/find-common-elements-three-sorted-arrays/ "we can find the common elements using a single loop and without extra space."

Please explain to me why you think the jewels & stone problem is similar to the one above.

I was also asked during an interview recently at a Fang company to solve three sum problem without using any hash and using pointers and while loops alone for similar O(nlogn) solution.

And even if you went to the moon riding on a broomstick, it does not change that your 2 pointers approach to the jewels & stones problem is simply "using a sword to catch birds".

I don't think "I'll solve it in C" was the answer they were looking for.

I'll solve it in C in the context of using no extra space is a valid answer. How would you do that? Would you use python?

1

u/[deleted] Feb 18 '21

Oh I see. you mean declaration of variables when it comes to intermediate data.

So it's not so much the jewels & stones problem in relation to the finding common elements in array problem. What I was saying is that if you transform the jewels and stones into arrays where their chars are converted to ints, it's the same as the finding common elements problem. This is one way in which you don't have to use extra space to solve this problem, so no hash needed.

1

u/Kengaro Feb 18 '21

Your agrumentation contradicts itself, as transforming data structures does changes the amount of memory used. However you seem to have no intention to widen your understanding of the things we are talking about. Alas I see no point in futher conversation.

1

u/[deleted] Feb 18 '21

?? I'm trying to learn this stuff from you. I've been getting this "you're myopic and not interested in learning different things" from this thread quite often when it's always been the opposite, I'm not sure if it's just how internet messaging is being carried out or if that's how most people act so assumptions are made.

Anyway, yea to close off the convo I understand that changing data structures does require memory usage. My question was a bit more broad in asking, if we ignore transformation of jewels and stones to its array form, can we consider this to be no extra space memory allocation and similar to the problem I shared with you? I mentioned this ignoring part earlier but I'm not sure if it was this thread since it was a while ago