PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Bytedance

Find Top Creators and Login Streaks

Last updated: May 2, 2026

Quick Overview

This question evaluates proficiency in data aggregation, algorithmic optimization for top-k retrieval, and SQL time-series analysis using window functions and date deduplication to compute consecutive-day login streaks.

  • medium
  • Bytedance
  • Coding & Algorithms
  • Data Engineer

Find Top Creators and Login Streaks

Company: Bytedance

Role: Data Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Solve the following two interview-style tasks. ### Task 1: Top creators by likes You are given a list of like events for a business-facing creator platform. Each event contains: - `viewer_id`: the user who liked the content - `creator_id`: the creator who received the like - `created_at`: timestamp of the like Implement a function that returns the top `k` creators ranked by total number of likes received. Requirements: - Count all like events by `creator_id`. - Return the top `k` creators sorted by like count in descending order. - If two creators have the same like count, sort by `creator_id` in ascending order. - Discuss the time and space complexity. - Optimize the solution for the case where the number of creators is very large and `k` is much smaller than the number of creators. ### Task 2: Consecutive login days in SQL You are given a table `user_logins`: ```sql user_logins( user_id BIGINT, login_date DATE ) ``` A user may have multiple login records on the same date. Write a SQL query, or explain the SQL approach, to compute each user's longest streak of consecutive login days. Requirements: - Treat multiple logins on the same date as one login day. - Consecutive days must differ by exactly one calendar day. - Return `user_id` and `longest_streak`. - Use window functions where appropriate.

Quick Answer: This question evaluates proficiency in data aggregation, algorithmic optimization for top-k retrieval, and SQL time-series analysis using window functions and date deduplication to compute consecutive-day login streaks.

Related Interview Questions

  • Minimize Increments to Equalize Path Costs - Bytedance (medium)
  • Implement Sorted Search and Array Updates - Bytedance (medium)
  • Find Maximum Candies With Two Types - Bytedance (medium)
  • Place Non-Attacking Queens - Bytedance (hard)
  • Compute Minimum Parentheses Additions - Bytedance (medium)
Bytedance logo
Bytedance
Mar 12, 2026, 12:00 AM
Data Engineer
Onsite
Coding & Algorithms
0
0
Loading...

Solve the following two interview-style tasks.

Task 1: Top creators by likes

You are given a list of like events for a business-facing creator platform. Each event contains:

  • viewer_id : the user who liked the content
  • creator_id : the creator who received the like
  • created_at : timestamp of the like

Implement a function that returns the top k creators ranked by total number of likes received.

Requirements:

  • Count all like events by creator_id .
  • Return the top k creators sorted by like count in descending order.
  • If two creators have the same like count, sort by creator_id in ascending order.
  • Discuss the time and space complexity.
  • Optimize the solution for the case where the number of creators is very large and k is much smaller than the number of creators.

Task 2: Consecutive login days in SQL

You are given a table user_logins:

user_logins(
  user_id BIGINT,
  login_date DATE
)

A user may have multiple login records on the same date.

Write a SQL query, or explain the SQL approach, to compute each user's longest streak of consecutive login days.

Requirements:

  • Treat multiple logins on the same date as one login day.
  • Consecutive days must differ by exactly one calendar day.
  • Return user_id and longest_streak .
  • Use window functions where appropriate.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Bytedance•More Data Engineer•Bytedance Data Engineer•Bytedance Coding & Algorithms•Data Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.