remove single elements - MATLAB Cody - MATLAB Central

Problem 2456. remove single elements

Difficulty:Rate
Given a vector of integers, remove the elements that have appeared only once. The output elements should be in exact order as the input except the single elements being removed.
Example:
Input: vec = [2 2 1 2 3 4 1 2];
Output: [2 2 1 2 1 2];
Loops are not allowed.

Solution Stats

31.24% Correct | 68.76% Incorrect
Last Solution submitted on Nov 16, 2025

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...

Problem Recent Solvers123

Suggested Problems

More from this Author44

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!