Problem 2456. remove single elements
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
Problem Comments
-
4 Comments
Show
1 older comment
shahriar memaran
on 25 Mar 2017
Test suit # 4 should not compare out = [] with output of the function but rather isempty(out) !!!
Christian Schröder
on 21 Oct 2022
Two requests:
1. Please don't add intentional infinite loops to the test suite.
2. Please take more care when scanning for forbidden keywords. "x(grouptransform(x', x', @numel) > 1)" would be a perfectly good solution, but fails the test suite because "grouptransform" contains the letters "for".
Thanks.
Dyuman Joshi
on 22 Oct 2022
Test suite has been updated -
The infinite loop has been cleared out, scanning for 'for' loop has been modified and empty sets will now be verified using isempty().
Solution Comments
Show commentsGroup

Magic Numbers III
- 15 Problems
- 10 Finishers
- Champernowne Constant
- Pandiagonal Prime Magic Square Verification
- Make a Pandiagonal Prime Magic Square: 11 x 11
- Fangs of a vampire number
- Find all vampire fangs
- is the number happy?
- Pandigital number n°1 (Inspired by Project Euler 32)
- Pandigital number n°2 (Inspired by Project Euler 32)
- Pandigital number n°3 (Inspired by Project Euler 32)
- Pandigital Factors (Based on Euler 491)
- Dudeney Numbers: Numbers which are the cube of their decimal sum
- Factorions: Numbers that equal the sum of the factorials of their digits
- Optimum Egyptian Fractions
- Prime Ladders
- Leftovers? Again?!
Problem Recent Solvers112
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!