PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/TikTok

Solve pair-counting and account-merging problems

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in algorithmic problem-solving for pair counting and entity consolidation, focusing on efficient array processing, threshold-based counting, and merging records by shared identifiers, and it falls under the Coding & Algorithms domain.

  • medium
  • TikTok
  • Coding & Algorithms
  • Software Engineer

Solve pair-counting and account-merging problems

Company: TikTok

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem A — Count qualifying products You are given two integer arrays `A` and `B`, and an integer `T`. For each element `a` in `A`, count how many elements `b` in `B` satisfy: \[ a \times b \ge T \] Return an array `ans` of length `len(A)` where `ans[i]` is the count for `A[i]`. ### Input/Output - **Input:** integers arrays `A`, `B`, integer `T` (all non-negative). - **Output:** integer array `ans`. ### Constraints (typical interview scale) - `1 <= len(A), len(B) <= 1e5` - `0 <= A[i], B[i] <= 1e5` - `0 <= T <= 1e10` --- ## Problem B — Merge user accounts by shared identifiers You are given a list of accounts. Each account is a list of strings: - The first string is a **user name**. - The remaining strings are **identifiers** (e.g., emails). Two accounts belong to the same real user if they share **at least one identifier** (directly or transitively). Merge all accounts that belong to the same user. ### Output format Return the merged accounts as a list where each merged account is: - `[name, id1, id2, ...]` - Identifiers must be **unique** and **sorted lexicographically**. - You may output merged accounts in any order. ### Notes - If multiple accounts with different names get connected via identifiers, assume the name for the merged result can be taken from any one of the connected accounts (state your choice). ### Constraints (typical interview scale) - `1 <= number_of_accounts <= 1e4` - Total number of identifiers across all accounts `<= 1e5`

Quick Answer: This question evaluates proficiency in algorithmic problem-solving for pair counting and entity consolidation, focusing on efficient array processing, threshold-based counting, and merging records by shared identifiers, and it falls under the Coding & Algorithms domain.

Related Interview Questions

  • Parse a nested list from a string - TikTok (medium)
  • Implement stacks, streaming median, and upward path sum - TikTok (easy)
  • Maximize sum with no adjacent elements - TikTok (medium)
  • Implement stack variants and path-sum check - TikTok (medium)
  • Find the longest palindromic substring - TikTok (easy)
TikTok logo
TikTok
Dec 8, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

Problem A — Count qualifying products

You are given two integer arrays A and B, and an integer T.

For each element a in A, count how many elements b in B satisfy:

a×b≥Ta \times b \ge Ta×b≥T

Return an array ans of length len(A) where ans[i] is the count for A[i].

Input/Output

  • Input: integers arrays A , B , integer T (all non-negative).
  • Output: integer array ans .

Constraints (typical interview scale)

  • 1 <= len(A), len(B) <= 1e5
  • 0 <= A[i], B[i] <= 1e5
  • 0 <= T <= 1e10

Problem B — Merge user accounts by shared identifiers

You are given a list of accounts. Each account is a list of strings:

  • The first string is a user name .
  • The remaining strings are identifiers (e.g., emails).

Two accounts belong to the same real user if they share at least one identifier (directly or transitively). Merge all accounts that belong to the same user.

Output format

Return the merged accounts as a list where each merged account is:

  • [name, id1, id2, ...]
  • Identifiers must be unique and sorted lexicographically .
  • You may output merged accounts in any order.

Notes

  • If multiple accounts with different names get connected via identifiers, assume the name for the merged result can be taken from any one of the connected accounts (state your choice).

Constraints (typical interview scale)

  • 1 <= number_of_accounts <= 1e4
  • Total number of identifiers across all accounts <= 1e5

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More TikTok•More Software Engineer•TikTok Software Engineer•TikTok Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,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.