PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/TikTok

Solve linked list, string filtering, and puzzle

Last updated: Mar 29, 2026

Quick Overview

This multi-part question evaluates proficiency with linked-list pointer manipulation and constant-space linear-time algorithms, pattern-driven string transformation with attention to iteration semantics and edge-case handling, and combinatorial reasoning about constrained resource partitioning.

  • medium
  • TikTok
  • Coding & Algorithms
  • Software Engineer

Solve linked list, string filtering, and puzzle

Company: TikTok

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Coding & Algorithms (3 tasks) ### 1) Find the 5th node from the end (singly linked list) You are given the head pointer of a **singly linked list**. - Return the **value** of the node that is the **5th from the end** (i.e., counting from the tail: tail is 1st). - If the list has fewer than 5 nodes, specify a reasonable behavior (e.g., return `null` / throw an error). **Constraints:** Aim for \(O(n)\) time and \(O(1)\) extra space. --- ### 2) Remove “camel-pattern” triplets from a string Given a string `s` (ASCII letters only), remove every contiguous length-3 substring `s[i..i+2]` that matches the pattern: - `s[i] == s[i+2]` (exact same character), and - `s[i]` and `s[i+1]` have **different letter cases** (one uppercase, one lowercase). After removals, the remaining parts are concatenated. **Example** - Input: `"AaADbDEeEbcvQv"` - Output: `"bc"` Clarify whether removals are **single pass** or **repeated until no more matches**; design your solution accordingly. **Constraints:** \(1 \le |s| \le 2\times 10^5\). --- ### 3) Gold bar daily pay puzzle A worker works **7 days** and is paid **one gold bar** total. The bar can be broken into pieces with **at most two breaks**. - How can you pay the worker **each day** such that the daily payment is equal (i.e., each day receives exactly \(\tfrac{1}{7}\) of the total bar value)? - You may exchange pieces back and forth each day (give/take pieces) as long as the net pay per day is correct.

Quick Answer: This multi-part question evaluates proficiency with linked-list pointer manipulation and constant-space linear-time algorithms, pattern-driven string transformation with attention to iteration semantics and edge-case handling, and combinatorial reasoning about constrained resource partitioning.

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
Jan 6, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0
Loading...

Coding & Algorithms (3 tasks)

1) Find the 5th node from the end (singly linked list)

You are given the head pointer of a singly linked list.

  • Return the value of the node that is the 5th from the end (i.e., counting from the tail: tail is 1st).
  • If the list has fewer than 5 nodes, specify a reasonable behavior (e.g., return null / throw an error).

Constraints: Aim for O(n)O(n)O(n) time and O(1)O(1)O(1) extra space.

2) Remove “camel-pattern” triplets from a string

Given a string s (ASCII letters only), remove every contiguous length-3 substring s[i..i+2] that matches the pattern:

  • s[i] == s[i+2] (exact same character), and
  • s[i] and s[i+1] have different letter cases (one uppercase, one lowercase).

After removals, the remaining parts are concatenated.

Example

  • Input: "AaADbDEeEbcvQv"
  • Output: "bc"

Clarify whether removals are single pass or repeated until no more matches; design your solution accordingly.

Constraints: 1≤∣s∣≤2×1051 \le |s| \le 2\times 10^51≤∣s∣≤2×105.

3) Gold bar daily pay puzzle

A worker works 7 days and is paid one gold bar total. The bar can be broken into pieces with at most two breaks.

  • How can you pay the worker each day such that the daily payment is equal (i.e., each day receives exactly 17\tfrac{1}{7}71​ of the total bar value)?
  • You may exchange pieces back and forth each day (give/take pieces) as long as the net pay per day is correct.

Comments (0)

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 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.