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
Solution Comments
Show comments
Loading...
Problem Recent Solvers131
Suggested Problems
-
Find the largest value in the 3D matrix
1666 Solvers
-
Return a list sorted by number of consecutive occurrences
429 Solvers
-
Determine the number of odd integers in a vector
826 Solvers
-
Celsius to Fahrenheit converter
666 Solvers
-
Matlab Basics - Convert a row vector to a column vector
678 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!
Since matlab has so many different ways of representing the empty set, could you test for emptiness using isempty(...) rather than isequal([], ...) ?
Test suit # 4 should not compare out = [] with output of the function but rather isempty(out) !!!
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.
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().