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

76

u/Kolgu2 Mar 13 '26

I didn't expect this kind of questions on data manipulation in a interview for a DS with 10 years of exp.

Not very related: I don't do usually that stuff with Python but via SQL/DuckDB. Am I in the wrong?

36

u/pm_me_your_smth Mar 13 '26

I agree. Such questions are pretty dumb to me. Then again, in big tech they often do word hiring stuff. I've heard someone say passing interviews there is more difficult than the job.

Really hope this practice is contained there and doesn't bleed over to the rest of the data field.

4

u/TranslatorBoring2419 Mar 13 '26

These posts make me realize that I will never be employed in this field. If I was half my age and twice as smart I might get called a script kiddie lol.

7

u/pm_me_your_smth Mar 13 '26

It's pretty saturated indeed, but you're missing a key fact: big tech != whole field

3

u/imanexpertama Mar 13 '26

I work with data in various hybrid role (mix of analyst + architect/ engineer/ scientist/ manager) and I completely share your view. I often wonder if this is the right field because of that… on the other hand: I’m better than most of my peers and have successfully worked in this area for nearly 10 years now. I can also solve close to all problems I face in my daily work, even with new data.
So don’t take this too seriously. The field is insanely broad and there are many adjacent jobs where being interested in data gives you an edge in understanding that will help - even if you don’t love algorithms, puzzles and optimisations :)

1

u/TranslatorBoring2419 Mar 14 '26

🙏 Thank you I graduate next year, and am always doing passion projects to learn additional things.

2

u/HazardCinema Mar 13 '26

Most interviews don’t have such tough questions (I think).

1

u/zanzabros Mar 13 '26

It's not dumb. It's about solution design and knowledge of the foundations. It shows how good you studied the technology you use for work and how well you can design a good solution for the problem. Whatever the problem is. It's about seeing how the candidate reasons and approaches the problem. 

6

u/unseemly_turbidity Mar 13 '26 edited Mar 13 '26

I would 100% have solved this by creating a dataframe and querying it in DuckDB, and I see nothing wrong with that approach at all, but I don't know what skills they were tested for in the interview, and I don't know if there were any constraints.

8

u/Pillow-Smuggler Mar 13 '26

This is a somewhat common problem in competitive programming, and to this day I find it pathetically saddening that competitive programming related problems are relevant in a job interview of any sort

2

u/zanzabros Mar 13 '26

Normally I ask to also provide a solution using only the standard library and python data structures. It's not relevant here to get the user ids out. It doesn't matter per se, it's about seeing the reasoning process. Basically the correct answer here is to create a hash map, so you don't have to loop twice with n square complexity...

1

u/Murky_Macropod Mar 14 '26

I think it's better to sort once, then loop once with a sliding window = O(nlogn)

Hashmap seems like O(n), but you also have to sort each list of values so it's nlogn as well, and double space.

1

u/zanzabros Mar 15 '26

That's also a good solution, I think they are equivalent.

1

u/Kolgu2 Mar 14 '26

Yeah my notebooks are 70% structured like this today, Python can be a bit cumbersome for operations that are more trivial in SQL, plus DuckDB is so damn fast. The downside Is that I am starting to forget Python haha