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

2

u/beginner_ Feb 16 '21

For example if you had 100 stones and 100 jewels and you had a bad implementation of counting them, you'd end up with O(m * n) which is 10 000 operations.

Which is at most a couple milliseconds on a modern CPU. Yeah it doesn't scale but if it takes me 5 min to build and 5ms to run it's still faster than 1h to build and 100ns to run. Hyperbole yes but pure execution performance isn't the only thing that matters. Besides development speed, code readability matters too.

If you know it's one-off code or you never will have to really scale behind a couple thousands rows why bother with a perfect algorithm? premature optimization.

I could argue if you have really big data, your hashtable wont fit in memory. What do you do then? You assumed it fits which probably is true for any reasonable case so why bother with a solution that doesn't fit? I assume I never have large amount of data so why invest time for perfect time complexity?

Having said that I never really dealt with leetcode so no idea what level the questions are. Ok, if they are on the stone jewels or fizzbuzz level makes sense to weed out the worst of the worst but DFS implementations or brain teasers is something else entirely.

0

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

Okay. What about 100 000 stones and 10 000 jewels? That might take a long time to run (1 billion operations) vs. getting it done in 100 000 operations. Datasets with 100 000 data points aren't that rare. It's very common to even have an excel file with 100 000 rows.

It is super important to understand this and to recognize situations where this type of thing can occur. When I do stones & jewels, it makes me feel dirty to iterate over something and then iterate over something else because I know it's trouble. I might put a comment as a reminder to fix it later and if shit's too slow, that's the first place I'd look into optimizing.

Indexes can be distributed over multiple nodes. For example that's how Cassandra or other types of database sharding works. These simple fundamental concepts translate to basically everything you do on a computer. That's why understanding them is so important.

Things like hash tables can be thought of buckets and a function that tells you which bucket it is. Doesn't matter if the buckets are in memory, on disk, on a different computer or in a tape archive. Once you understand the basic idea, you'll start seeing the same concept everywhere.

1

u/[deleted] Feb 16 '21

Most of the time especially with relational data/tabular data you would be using tidyverse and pandas tools to get the job done. There is no need to even think about string algorithms, as stringr essentially does it all for you. The idea is all this stuff like sorting, string algorithms, data cleaning, etc is made easy by these tools so you can focus on getting the statistics correct.

There are tons of statistical nuances in many datasets. One that comes up semi often was having truncated 0s for a measurement below a limit of detection. Extremely common in any sort of biochemical assay like ELISA. I see questions that probe into things like “how would you handle this situation in an ML model” as far more relevant to DS. There are multiple valid answers (various types of imputation, using censored loss functions, Tweedie loss, and more each with pros+cons) but this is how you truly differentiate those who use model.fit() vs those who understand what stat/ML is. It gives insight into how they would think too.

Leetcode to separate those who just go model.fit() doesn’t make sense. Like it essentially filters out statistical ML candidates who might be expecting something entirely different and can be valuable too.

0

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

And what do you do before you get it into a pandas or R dataframe? I've worked for a long time and I haven't seen perfectly preprocessed data in dataframes out in the wild. Someone had to create those and that's probably you.

For example in a relational database you have normalized data. It's not a 2D matrix or a 1D vector. It might be 5D. How do you go from having nested relations where a single "column" is in fact a table that contains more tables and so on?

Sure, you could do a full join but that's going to end up a giant mess. You're supposed to do feature engineering and data cleaning at this step. And that will involve thinking about trying to do everything in one pass instead of doing "for each element of X go through each element of Y".

Asking ML trivia is stupid. The field is HUGE and it's pretty idiotic to ask questions about data imputation because it's a teeny tiny thing as far as data science is concerned. It's just random luck whether a person in front of you has done data imputation recently or not. It says absolutely nothing about their competence. Anyone can learn everything there is about data imputation in a month of research.

The industry standard is to ask the fundamentals that apply to everything. Every kind of data scientist needs to understand how programming works, how statistics work, how math work etc. It doesn't matter if they're handling time series in finance or images in medical research or brain waves in psychology research and so on. Every single type of data scientist needs the same basic concepts. Those are the ones you ask about.

Stuff specific to your company? Anyone that knows the basics will be capable of learning it. I'd hire someone that spent 10 years in NLP to do computer vision if they know the basics over someone that doesn't know the basics but did 10 years of computer vision.

We are not talking about doing everything from scratch on a daily basis. We're talking about understanding how the tools you're using work and what kind of things you should be taking into account when making decisions.

1

u/[deleted] Feb 16 '21

Its not just data imputation, there were other methods too but that was an example just in general that there are a bunch of statistical nuances. Ive seen CS people use MSE for ordinal multiclass data for example and statistically that is just stupid.

As for the RDMS stuff with a column of vectors/matrices, Julia can handle this stuff just fine as the dataframe columns can contain vectors of any type (eg vectors of dataframes itself). The CS DS&A is becoming more and more irrelevant with these shortcuts. But this particularly sounds like a database design thing and if data is really like that chances are there is a standardized way DEs have come up with to handle it and communicate that. As far as I see this is stuff specific to a company too

Deep programming data structures and algorithms often does not come up in most sotuations. Its not like you are doing this in low level C++/Java where stuff like DS&A may be necessary. Most of it can be treated as a black box.

I find that the CS ML people treat the stats ML as a black box while stats ML people are vice versa. You can be competent at ML without ever learning DS&A, and it is taught in a DS&A free way in stats departments.

1

u/[deleted] Feb 16 '21

I don't think you understand what I am talking about which is why you're confused. Take a DS&A course and you'll understand precisely why this is important.

You're just spewing irrelevant nonsense. DS&A is necessary in EVERYTHING you do related to code. You have to think about DS&A in excel or drag&drop tools as well.

1

u/beginner_ Feb 17 '21

Okay. What about 100 000 stones and 10 000 jewels? That might take a long time to run (1 billion operations) vs. getting it done in 100 000 operations. Datasets with 100 000 data points aren't that rare. It's very common to even have an excel file with 100 000 rows.

Again I never said it scales. 1 billion operations sounds like a lot but it's just character (byte) comparisons and modern CPUs are extremely fast. You can still measure it in seconds maybe minute(s) on a modern laptop. Albeit I'm open to you proofing me wrong.

You also broke the definition of the problem. jewels can only be English letters. So you can't have more than 52 jewels. This is the point you are missing. If your big data use case can be exclude with 100% certainty any extreme optimization is a premature optimization.

100k rows excel might be common in your industry, it's not in mine. Also only straight forward use-case of m*n is probably KNN if done naively. But then again, why would I implement this myself? I know my limitations and it's just a waste of time reinventing the wheel.

Things like hash tables can be thought of buckets and a function that tells you which bucket it is. Doesn't matter if the buckets are in memory, on disk, on a different computer or in a tape archive. Once you understand the basic idea, you'll start seeing the same concept everywhere.

Where you hastable is certainly matters for the resulting performance and that was your main point of using them vs a "naive brute-force" method.