Home/Algo Bridge/Fast-Slow Pointers/LC_26
⚡ Practice in Flashcards
🌉 Problem-Level AI BridgeLC_26 · 简单

LC_26 (Remove Duplicates from Sorted Array) ➔ SFT Data Formatting & Token Loss Masking

Fast-slow pointers allow in-place modification of token tensors and mask alignment without allocating secondary buffers, saving critical GPU memory.

1️⃣ 1️⃣ Classical DSA Origin

LC_26 · Remove Duplicates from Sorted Array

Pattern: Fast-Slow Pointers — Fast pointer explores bounds, step jumps, or sweeps through tokens; slow pointer maintains in-place output boundaries or advances at a 2:1 ratio to detect cyclic loops and midpoints in O(N) time and O(1) space.

⚡ Open LC-26 Solution ➔
2️⃣ 2️⃣ Production AI System Transfer

SFT Data Engineering, Packaging & Loss Masking · SFT Data Formatting & Token Loss Masking

Industrial Application: Rearranges token sequences in SFT data pipelines, assigning label -100 to prompt tokens while computing loss strictly on response tokens.

🧬 Target AI Kernel Interface
def collate_sft_conversation(prompt_tokens: list[int], response_tokens: list[int], max_len: int = 512, pad_token_id: int = 0) -> tuple[torch.Tensor, torch.Tensor]

🔗 Related Algorithmic Bridges

LC_141 ➔ Pipeline Parallel Bubble Ratio (1F1B Schedule)
Floyd's cycle detection guarantees discovering cyclic loops in finite st...
LC_141 ➔ Pipeline Parallel Bubble Ratio (1F1B Schedule)
Floyd's cycle detection safeguards autonomous multi-agent DAGs from infi...
LC_141 (Linked List Cycle) → Distributed Training, Collective Communication & 1F1B Pipeline →