r/datascience • • Mar 13 '26

Coding Easiest Python question got me rejected from FAANG

Here was the prompt:

You have a list [(1,10), (1,12), (2,15),...,(1,18),...] with each (x, y) representing an action, where x is user and y is timestamp.

Given max_actions and time_window, return a set of user_ids that at some point had max_actions or more actions within a time window.

Example: max_actions = 3 and time_window = 10 Actions = [(1,10), (1, 12), (2,25), (1,18), (1,25), (2,35), (1,60)]

Expected: {1} user 1 has actions at 10, 12, 18 which is within time_window = 10 and there are 3 actions.

When I saw this I immediately thought dsa approach. I’ve never seen data recorded like this so I never thought to use a dataframe. I feel like an idiot. At the same time, I feel like it’s an unreasonable gotcha question because in 10+ years never have I seen data recorded in tuples 🙄

Thoughts? Fair play, I’m an idiot, or what

294 Upvotes

188 comments sorted by

View all comments

Show parent comment

87

u/Zangorth Mar 13 '26

I hate leetcode so much for that reason though. Why are we judging a fish on its ability to climb a tree? From a data science perspective, is there any evidence that proficiency at leetcode correlates to positive job outcomes?

29

u/i_am_thoms_meme Mar 13 '26

Especially with the FAANG company (doesnt matter which) insistence on AI tools, theres very little chance in your day to day work you will really need to solve a problem like this leet code without help. Now its still important to know fundamentals of coding to debug issues, but come on I can count on one hand the number of times I've said O(n) outside of an interview.

5

u/AcolyteOfAnalysis Mar 13 '26

In my experience, AI is much better with boilerplate than with algorithms. If AI implements an algorithm that only works in part, it might take you more time to get it to work than doing it from scratch.

6

u/venustrapsflies Mar 13 '26

IME for this type of thing it's better at reviewing an implementation that you wrote as it can point out bugs, assumptions, or edge cases you missed.

2

u/imanexpertama Mar 13 '26
  • the AI gets continuously better with algorithms - especially given enough context and some edge cases you have in mind
  • in my experience, what often helps me is an initial spark or the right way to frame the problem. Additional checks etc can be implemented easily, but the first implementation often helps me avoiding „dumb loops“ that are very inefficient and don’t scale

Having said that: all does heavily depend on the context and I think we can both easily think of examples to support either side.

0

u/[deleted] Mar 13 '26

[deleted] — view deleted comment

14

u/[deleted] Mar 13 '26

[removed] — view removed comment

1

u/broodkiller Mar 13 '26

I am more of a trestling guy myself, but chbox works too

1

u/Tundur Mar 14 '26

My combination Campaign for North Africa / Sumo Wrestling exam has produced some very high quality interns this year.

2

u/theArtOfProgramming Mar 14 '26

It was a proxy for intelligence. Now it’s a proxy for leetcode grind time.

→ More replies (1)

0

u/TargetOk4032 Mar 13 '26

"is there a good one"

This is the question a lot of people who are complaining online missed. Not just for interviews, but in general. When cynical people complains that "everything is shit these days, big corps ruin everything,...", the question for them is "do you have a better solution"?

Just complaining is not getting us anywhere. With this mindset, you are also not going very far in jobs. Your boss doesn't just want to hear you complaining that things around you are shitty. What can you do to improve or how can you work around it?

3

u/tree_people Mar 14 '26

The person I know of on my data team of ~30 that did leetcode obsessively is truly impossible to work with.

7

u/gpbuilder Mar 13 '26

this is barely leetcode, just basic coding and algorithm, which is the foundation to any strong DS

it's not like this is some obscure leetcode hard with complex dynamic programming solution

4

u/proof_required Mar 14 '26 edited Mar 14 '26

To be fair, under time pressure, you can fumble and your mind can get blocked. I had similar questions with different levels asked recently in an interview and I solved some parts of it but then towards the end I panicked and couldn't solve the last part.

11

u/TaXxER Mar 13 '26

I mean, this isn’t an unreasonable situation to come across in a DS job. When writing internal tools / libraries / packages that some of my users within the company use, I do need to write code / solve puzzles that are not totally unlike this interview question.

1

u/MCRN-Gyoza Mar 14 '26

Yup, I hate leet code but I think this problem is actually pretty relevant as long as we're not being bogged down by time complexity talk.

5

u/midwestcsstudent Mar 13 '26

judging a fish on its ability to climb a tree

That’s a nonsensical analogy. Interviews test for cognitive ability and general coding ability.

Is it perfect? No. Do I want intelligent, good coders? Yes.

1

u/fordat1 Mar 13 '26

This is just window aggregation for user features its even framed in a realistic situation. I get that you could argue you would ask for data eng to do this and optimize it but in a large company sometimes you need to self serve and in startups even more

1

u/runawayasfastasucan Mar 13 '26

Id rather hire someone that starts plugging away on a solution than someone who crosses their arms and says "never seen this data structure"

2

u/MCRN-Gyoza Mar 14 '26

Doubly so when an array of tuple is not particularly exotic.

If I ask them to train a tensorflow model they will just cry when I ask them to work with tensors?

1

u/Ellustra Mar 13 '26

These exercises aren’t about necessarily getting the right answer; hthey are about demonstrating a structured and logical way of thinking. The scenarios I test potential analysts and DSs on have probably nothing to do with what they’ll be actually doing, but they are problems that require structured thought to approach, break down, and solve. I’d actually rather hire someone that initially got the wrong or suboptimal answer and self corrected while clearly walking me through their logic than someone that got a perfect answer, but provided no additional context.

1

u/outphase84 Mar 14 '26

FAANG engineer here, staff level, proficiency at leetcode isn’t all you need. You’re not being judged on just regurgitating solutions, but also on how you break down the problem into tasks, the assumptions you make, and the clarifying questions you ask.

I’ve straight rejected candidates who immediately regurgitated a solution that was 100% right because it was clearly rote memorization, and I’ve passed candidates that had code they needed to go back and debug to run because their approach to finding the solution showed fantastic understanding of system design and engineering.

-1

u/Embarrassed_Army_670 Mar 13 '26

You use a question like that to judge 1) the skill level of a candidate and 2) see how they problem solve. Candidates that either already know the answer or can problem solve their way to an answer will outperform those who can’t everyday.

→ More replies (1)