Cody

# Problem 53. Duplicates

Solution 1457353

Submitted on 6 Mar 2018 by Russell
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   Pass
strs = {'aa','bb','aa','aa'}; correct = {'aa'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

ndx = 4 outlist = 0×0 empty cell array k = 3 outlist = 1×1 cell array {'aa'} ndx = 3 k = 3 outlist = 1×2 cell array {'aa'} {'aa'} ndx = 2 k = 1 ndx = 1 k = 3 outlist = 1×3 cell array {'aa'} {'aa'} {'aa'} ndx = 0 dups = 1×3 cell array {'aa'} {'aa'} {'aa'}

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

ndx = 3 outlist = 0×0 empty cell array k = 1 ndx = 2 k = 1 ndx = 1 k = 1 ndx = 0 dups = 0×0 empty cell array

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

ndx = 3 outlist = 0×0 empty cell array k = 3 outlist = 1×1 cell array {'zzz'} ndx = 2 k = 3 outlist = 1×2 cell array {'zzz'} {'zzz'} ndx = 1 k = 3 outlist = 1×3 cell array {'zzz'} {'zzz'} {'zzz'} ndx = 0 dups = 1×3 cell array {'zzz'} {'zzz'} {'zzz'}

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

ndx = 6 outlist = 0×0 empty cell array k = 2 outlist = 1×1 cell array {'c'} ndx = 5 k = 1 ndx = 4 k = 2 outlist = 1×2 cell array {'c'} {'b'} ndx = 3 k = 2 outlist = 1×3 cell array {'c'} {'b'} {'c'} ndx = 2 k = 2 outlist = 1×4 cell array {'c'} {'b'} {'c'} {'b'} ndx = 1 k = 1 ndx = 0 dups = 1×4 cell array {'c'} {'b'} {'c'} {'b'}

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

ndx = 0 outlist = 0×0 empty cell array dups = 0×0 empty cell array