PracHub
QuestionsLearningGuidesInterview Prep

Quick Overview

Practice removing duplicate strings globally while preserving first-seen order and leaving the input unchanged. Consider how the design changes when the input is too large to fit in memory.

  • medium
  • Vanta
  • Coding & Algorithms
  • Software Engineer

Remove Global Duplicates While Preserving Order

Company: Vanta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

# Remove Global Duplicates While Preserving Order Implement `global_unique(values)`. `values` is a list of strings. Return a new list containing the first occurrence of every distinct string and omit all later occurrences, even when equal values are not adjacent. The relative order of the retained values must be exactly the same as in the input. String comparison is case-sensitive. Do not modify the input list. ## Examples - `global_unique(["a", "b", "a", "c", "b"])` returns `["a", "b", "c"]`. - `global_unique([])` returns `[]`. - `global_unique(["x", "x", "x"])` returns `["x"]`. ## Constraints - `0 <= len(values) <= 200_000` - Each value is a valid Python string. ## Discussion follow-up After implementing the in-memory version, explain how you would process an input too large to fit in memory by partitioning work while still emitting the retained values in their original order.

Quick Answer: Practice removing duplicate strings globally while preserving first-seen order and leaving the input unchanged. Consider how the design changes when the input is too large to fit in memory.

Implement global_unique(values). Given a list of strings, return a new list containing only the first occurrence of each distinct string. Equality is case-sensitive, later duplicates may be non-adjacent, retained values keep their original order, and the input must not be modified. Non-graded discussion follow-up: explain how you would partition an input too large to fit in memory while still emitting retained values in original order.

Constraints

  • 0 <= len(values) <= 200,000
  • Every element is a string.
  • String comparison is case-sensitive.

Examples

Input: ([],)

Expected Output: []

Explanation: Covers first-occurrence retention and stable order.

Input: (['a'],)

Expected Output: ['a']

Explanation: Covers first-occurrence retention and stable order.

Hints

  1. Track values already retained in a hash set.
  2. Append a value only when it is first inserted into the set.
  3. Discussion only: a partitioned external-memory design must preserve the global first position of every value before its ordered emit phase.
Last updated: Jul 18, 2026

Loading coding console...

PracHub

Master your tech interviews with 9,000+ real questions from top companies.

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding 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.

Related Coding Questions

  • Implement Adjacent-Line Uniq - Vanta (medium)
  • Implement a Unique Lines Command - Vanta (easy)
  • Order Classes by Prerequisites with Recursive DFS - Vanta (medium)
  • Implement a uniq-like function - Vanta (medium)