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

10

u/[deleted] Feb 16 '21

Because to do O(n) using hashes you need extra space complexity O(n). By doing O(nlogn) you're sacrificing runtime for no extra space. One basic principle of SWE is tradeoff between these two and what makes sense to use given problem at hand. There are times when interviewers specifically ask for no extra space. Usually those require O(n) runtime using some fancy algorithm you had to memorize. I've found that O(nlogn) using pointers after sorting can work in many situations when you don't memorize those algorithms. Good and understanding interviewers also realize this and usually ask you to solve in O(nlogn) after sorting and using one or two pointers using while loops or recursions

-2

u/[deleted] Feb 16 '21

And why do you think that you need extra space to store the jewels in a set (or the counts in a dict) as opposed to storing them in some other data structure?

2

u/prosocialbehavior Feb 16 '21

you lose

2

u/[deleted] Feb 16 '21

Lose what?

Space complexity of using a hash table (so set or dictionary for example) is exactly the same as using an array (such as a list) or any other data structure. It's O(n). There is literally no reason not to use it in this case. You have to store the data somewhere anyway so might as well use proper data structure for the task at hand.

There is no tradeoff. There is a bad solution and there is a good solution.

1

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

Dude what you said is so wrong it's not even on the map. What if I then asked the same Jewels question but said no extra space complexity (just O(1) no O(n) like hashmaps). What would you do then? Now there is "literally every reason not to use hashmaps".

The fact that you disregard tradeoffs between space and time complexity is really alarming. Actually SWEs would be horrified by your comment. The concept is literally called "Space–time tradeoff", it's on wikipedia under computer science. I'm kind of shocked by your answer and level of approach to CS questions, and beginning to suspect why data scientists are getting such bad rep on programming skills.

1

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

Are you dumb?

I have m stones in a list. It takes up O( m ) space. I have n jewels in a list. It takes up O( n ) space. Or I can just have n jewels in a dictionary. Still takes up O( n ) space. Or I can have n jewels in a set. Still O ( n ) space.

Space complexity doesn't change. It's still O ( m + n ). You have to store both the stones and jewels somewhere and IT DOES NOT MATTER where you store them or what the data structure is. It's still the same.

The way hashing works is that for each stone you have, you compute the hash and then look in the bucket the hash points to.

Compared to your dogshit algorithm, when using hashing you do not need to check every jewel. You don't care about all the jewels, you just compute the hash and get the answer right away. It does not matter if it's 3 jewels or 3 billion jewels. It will always take the exact same time to compute the hash. That is why it's O (1) time complexity. It does not depend on the size of the input.

The space complexity is exactly the same, you need to store both the jewels and the stones. It is not a tradeoff, it's simply a terrible algorithm (yours) and a good algorithm (the proper solution to the problem).

-1

u/[deleted] Feb 17 '21

wow you just don't get it haha. Forget the hashmap for a moment (which is what creates the extra space, not jewels or stones). The way you explain and try to persuade other professionals using expletives and triggered language is completely unprofessional and quite immature. Typical college student behavior, rarely see in working professionals I've worked with throughout the years. It's pretty alarming to see honestly.

To close off the convo, it's the creation of hashmap for storage that creates extra space. Nothing to do with jewels. Again, if I were to ask you to solve this problem without hashing and no other extra space, you can't just "compute the hash and get the answer right away" and tell the interviewers to gtfo and explain how hashing works. I hope for your sake you read on "space-time trade off" since it'll come up pretty frequently in interviews.

3

u/[deleted] Feb 17 '21

You don't need meaningful extra space to create a hash table. You don't need to copy things in full to shuffle things around in memory.

It is not a tradeoff. You are simply wrong and don't understand what you're doing.