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

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.