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 commentsProblem Recent Solvers112
Suggested Problems
-
28206 Solvers
-
508 Solvers
-
Vectorize the digits of an Integer
325 Solvers
-
287 Solvers
-
261 Solvers
More from this Author44
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!