Cody

# Problem 53. Duplicates

Solution 3877238

Submitted on 27 Nov 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
strs = {'aa','bb','aa','aa'}; correct = {'aa'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

strs = 4×2 char array 'aa' 'bb' 'aa' 'aa' buffer = "a" buffer = 1×2 string array "a" "a" buffer = 1×3 string array "a" "a" "a" buffer = 1×4 string array "a" "a" "a" "a" buffer = 1×5 string array "a" "a" "a" "a" "a" buffer = 1×6 string array "a" "a" "a" "a" "a" "a" dups = categorical a

Assertion failed.

2   Fail
strs = {'10','11','12'}; correct = {}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

strs = 3×2 char array '10' '11' '12' buffer = "1" buffer = 1×2 string array "1" "1" buffer = 1×3 string array "1" "1" "1" buffer = 1×4 string array "1" "1" "1" "1" buffer = 1×5 string array "1" "1" "1" "1" "1" buffer = 1×6 string array "1" "1" "1" "1" "1" "1" dups = categorical 1

Assertion failed.

3   Fail
strs = {'zzz','zzz','zzz'}; correct = {'zzz'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

strs = 3×3 char array 'zzz' 'zzz' 'zzz' buffer = "z" buffer = 1×2 string array "z" "z" buffer = 1×3 string array "z" "z" "z" buffer = 1×4 string array "z" "z" "z" "z" buffer = 1×5 string array "z" "z" "z" "z" "z" buffer = 1×6 string array "z" "z" "z" "z" "z" "z" dups = categorical z

Assertion failed.

4   Pass
strs = {'a','b','c','b','d','c'}; correct = {'b','c'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

strs = 6×1 char array 'a' 'b' 'c' 'b' 'd' 'c' buffer = "b" buffer = 1×2 string array "b" "c" buffer = 1×3 string array "b" "c" "b" buffer = 1×4 string array "b" "c" "b" "c" dups = 1×2 categorical array b c

5   Pass
strs = {}; correct = {}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

strs = 0×0 empty char array dups = 0×1 empty categorical array

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!