← ByteDance Interview Insights
The interviewer nudged me about duplicates partway through, which made me realize I'd written something that would count the same user multiple times if they posted more than once that day.
First, identify users who registered on a given day and users who published at least one post on a given day, then join these two sets on user_id and date to find users who did both on the same day. Finally, count the distinct user_ids from that intersection.
Pro tip: Mention that you would deduplicate posts per user per day before joining to avoid fan-out, and clarify whether 'same day' means calendar day in a specific timezone—this shows attention to data granularity and business context.
Confirm what 'registered' and 'published' mean (e.g., registration timestamp, post creation timestamp) and whether 'same day' is based on UTC or local timezone. State assumptions explicitly.
Select user_id and the date of registration from the users table, ensuring one row per user per registration day (typically one registration per user).
From the posts table, select distinct user_id and post date to get one row per user per day they published at least one post, collapsing multiple posts.
Inner join the registration user-day set with the post user-day set on user_id and date to keep only users who registered and posted on the same day.
Count distinct user_id from the joined result to get the total number of unique users who meet the condition.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.