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) !!!
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.
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
Project Euler: Problem 1, Multiples of 3 and 5
1525 Solvers
292 Solvers
Return elements unique to either input
556 Solvers
How many trades represent all the profit?
526 Solvers
138 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!