PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

Practice a Uber coding interview problem focused on maintain the first value that appears exactly once. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

  • hard
  • Uber
  • Coding & Algorithms
  • Software Engineer

Maintain the First Value That Appears Exactly Once

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Design a data structure that maintains a stream of integers and returns the first value that appears exactly once. Implement: ```python class FirstUniqueValue: def __init__(self, nums: list[int]): pass def show_first_unique(self) -> int: pass def add(self, value: int) -> None: pass ``` Return `-1` if no value is unique.

Quick Answer: Practice a Uber coding interview problem focused on maintain the first value that appears exactly once. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Simulate a stream supporting add and show_first_unique operations.

Examples

Input: {"initial":[2,3,5],"operations":[["show"],["add",5],["show"],["add",2],["show"],["add",3],["show"]]}

Expected Output: [2,2,3,-1]

Explanation: Classic stream.

Input: {"initial":[],"operations":[["show"]]}

Expected Output: [-1]

Explanation: Empty.

Input: {"initial":[1,1],"operations":[["show"]]}

Expected Output: [-1]

Explanation: No unique.

Input: {"initial":[1,2,1],"operations":[["show"]]}

Expected Output: [2]

Explanation: First remaining unique.

Input: {"initial":[7],"operations":[["show"],["add",7],["show"]]}

Expected Output: [7,-1]

Explanation: Unique becomes duplicate.

Input: {"initial":[1,2],"operations":[["add",3],["show"]]}

Expected Output: [1]

Explanation: Oldest unique.

Input: {"initial":[1,1,2],"operations":[["add",2],["add",3],["show"]]}

Expected Output: [3]

Explanation: New unique.

Input: {"initial":[4,5,4,6],"operations":[["show"],["add",5],["show"]]}

Expected Output: [5,6]

Explanation: Queue cleanup.

Last updated: Jul 4, 2026

Loading coding console...

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

  • Thread-Safe Token-Bucket Rate Limiter - Uber (medium)
  • Group Anagrams - Uber (medium)
  • Quadtree for 2D Geospatial Points - Uber (medium)
  • Deep Equality of Two Records - Uber (medium)
  • Shortest Path in a Grid with Blocked Cells - Uber (medium)