Problem 2456. remove single elements
Solution Stats
Problem Comments
-
2 Comments
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) !!!
Solution Comments
-
1 Comment
This cody problem is really nice. At first, I felt difficult to solve it without for or while. After that, I reached to a solution.
-
2 Comments
function A=removeSingle(A)
[n, bin] = histc(A, unique(A));
multiple = find(n ==1);
index = find(ismember(bin, multiple));
A(index)=[];
end
failed for 4 test suit help me
>> A = 1;A(1)=[];size(A)
ans =
1 0
>> size([])
ans =
0 0
Problem Recent Solvers69
Suggested Problems
-
948 Solvers
-
Sort numbers by outside digits
131 Solvers
-
Remove the two elements next to NaN value
515 Solvers
-
Calculate the Hamming distance between two strings
212 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
674 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!