JobsJob TrackerJob alerts

OneStack ยท 11 questions

All 11Coding 2System Design 2Behavioral 3Product Sense 1
  • Data structure for an O(1) LRU cacheSystem Design
  • Data structure for a spell checkerSystem Design
  • Output prediction and time complexity of code fragments
  • Keep only the first two occurrences of each elementCoding
  • Sorted insertion into a linked listCoding
  • Binary tree vs BST and BST complexity
  • ML project: model choice, dataset, epochs, CNN and RNNBehavioral
  • How Google Maps estimates travel timeProduct Sense
  • MySQL vs MongoDB and when to use each
  • Difficulty faced during a projectBehavioral
  • Healthy work environment, work-life balance, what to expect from youBehavioral
โ† OneStack questions
  1. Interview questions
  2. OneStack
  3. Keep only the first two occurrences of each element
Coding

Keep only the first two occurrences of each element

Filed under OneStack

The question

Given an integer array with repeats, keep the first and second occurrence of each value and delete third and later occurrences (example [0,1,1,2,5,3,1,3,3,3,5,5] gives [0,1,1,2,5,3,3,5]).

No write-up yet. Related questions below have one.

Related OneStack questions

  • Sorted insertion into a linked list
โ† Output prediction and time complexity of code fragmentsSorted insertion into a linked list โ†’

Collected from public candidate posts and coding forums. Updated Nov 2026.