Cody

# Problem 2699. From a given cell array of strings, extract the non-unique strings.

Solution 1967348

Submitted on 8 Oct 2019 by Augusto Mazzei
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
C = {'Ken'; 'GianCarlo'; 'Ken'; 'GianCarlo'; 'Bob'; 'Ken'; 'Sonia'}; repeatedStrings = {'Ken'; 'GianCarlo'}; assert(isequal(extractRepeatedStrings(C), repeatedStrings))

rep = 1×1 cell array {'Ken'} rep = 2×1 cell array {'Ken' } {'GianCarlo'} rep = 2×1 cell array {'Ken' } {'GianCarlo'}

2   Pass
C = {'A', 'B', 'C', 'A', 'B'}; repeatedStrings = {'A'; 'B'}; assert(isequal(extractRepeatedStrings(C), repeatedStrings))

rep = 1×1 cell array {'A'} rep = 2×1 cell array {'A'} {'B'} rep = 2×1 cell array {'A'} {'B'}

3   Pass
C = {'B', 'A', 'C', 'B', 'A'}; repeatedStrings = {'B'; 'A'}; assert(isequal(extractRepeatedStrings(C), repeatedStrings))

rep = 1×1 cell array {'B'} rep = 2×1 cell array {'B'} {'A'} rep = 2×1 cell array {'B'} {'A'}

4   Pass
C = {'A', 'B', 'C'}; repeatedStrings = cell.empty(0, 1); assert(isequal(extractRepeatedStrings(C), repeatedStrings))

rep = 0×1 empty cell array

5   Pass
C = {'A', 'B'; 'C', 'A'; 'B', 'A'}; repeatedStrings = {'A'; 'B'}; assert(isequal(extractRepeatedStrings(C), repeatedStrings))

rep = 1×1 cell array {'A'} rep = 2×1 cell array {'A'} {'B'} rep = 2×1 cell array {'A'} {'B'}

### Community Treasure Hunt

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

Start Hunting!