Cody

# Problem 95. Given two strings, find the maximum overlap

Solution 453948

Submitted on 12 Jun 2014 by Abdullah Caliskan
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
%% s1 = [1 2 3 4 5]; s2 = [5 4 3 2]; s3_correct = [1 2 3 4 5 4 3 2]; assert(isequal(overlap(s1,s2),s3_correct))

p = 4 f = Columns 1 through 8 1000 1000 1000 1000 1000 1 2 3 Columns 9 through 15 4 5 1000 1000 1000 1000 1000 H = [] k = 4 7 10 13 k = 1 5 8 12 15 16 r1 = 1 r2 = 2 r1 = 1 r2 = 0 r1 = 1 r2 = 1 r1 = 1 r2 = 3 B = 1 0 0 0 1 H = 1 0 0 0 1 H = 1 0 0 0 pp = 1

2   Pass
%% s1 = [1 0 1 7 7 7 6]; s2 = [1 0 1 0 1]; s3_correct = [1 0 1 0 1 7 7 7 6]; assert(isequal(overlap(s1,s2),s3_correct))

p = 5 f = Columns 1 through 8 1000 1000 1000 1000 1000 1000 1 0 Columns 9 through 16 1 7 7 7 6 1000 1000 1000 Columns 17 through 19 1000 1000 1000 H = [] k = 3 4 7 10 11 14 17 18 k = 1 2 5 6 9 13 r1 = 1 r2 = 4 r1 = 3 r2 = 2 r1 = 3 r2 = 0 r1 = 1 r2 = 0 B = 0 0 0 0 1 1 0 0 1 1 1 3 H = 0 0 1 1 1 3 H = 0 0 1 1 1 pp = 3

3   Pass
%% s1 = [3 1 4 1 5 9 2 6 5 3 5]; s2 = [9 2 6 5]; s3_correct = [3 1 4 1 5 9 2 6 5 3 5]; assert(isequal(overlap(s1,s2),s3_correct))

p = 4 f = Columns 1 through 8 1000 1000 1000 1000 1000 3 1 4 Columns 9 through 16 1 5 9 2 6 5 3 5 Columns 17 through 21 1000 1000 1000 1000 1000 H = [] k = 2 5 8 10 11 12 k = Empty matrix: 0-by-1 r1 = 1 r2 = 0 r1 = 4 r2 = 0 r1 = 1 r2 = 0 B = 1 1 1 1 4 H = 1 1 1 1 4 H = 1 1 1 1 pp = 4

4   Pass
%% s1 = 1:100; s2 = [50 51]; s3_correct = s1; assert(isequal(overlap(s1,s2),s3_correct))

p = 2 f = Columns 1 through 8 1000 1000 1000 1 2 3 4 5 Columns 9 through 16 6 7 8 9 10 11 12 13 Columns 17 through 24 14 15 16 17 18 19 20 21 Columns 25 through 32 22 23 24 25 26 27 28 29 Columns 33 through 40 30 31 32 33 34 35 36 37 Columns 41 through 48 38 39 40 41 42 43 44 45 Columns 49 through 56 46 47 48 49 50 51 52 53 Columns 57 through 64 54 55 56 57 58 59 60 61 Columns 65 through 72 62 63 64 65 66 67 68 69 Columns 73 through 80 70 71 72 73 74 75 76 77 Columns 81 through 88 78 79 80 81 82 83 84 85 Columns 89 through 96 86 87 88 89 90 91 92 93 Columns 97 through 104 94 95 96 97 98 99 100 1000 Columns 105 through 106 1000 1000 H = [] k = 1 2 k = Empty matrix: 1-by-0 r1 = 2 r2 = 0 B = 1 1 2 H = 1 1 2 H = 1 1 pp = 2

5   Pass
%% s1 = 90:10:200; s2 = 10:10:120; s3_correct = 10:10:200; assert(isequal(overlap(s1,s2),s3_correct))

p = 12 f = Columns 1 through 8 1000 1000 1000 1000 1000 1000 1000 1000 Columns 9 through 16 1000 1000 1000 1000 1000 90 100 110 Columns 17 through 24 120 130 140 150 160 170 180 190 Columns 25 through 32 200 1000 1000 1000 1000 1000 1000 1000 Columns 33 through 38 1000 1000 1000 1000 1000 1000 H = [] k = 9 10 11 12 k = 1 2 3 4 5 6 7 8 r1 = 4 r2 = 8 B = 0 0 0 0 0 0 0 0 1 1 1 1 4 H = 0 0 0 0 0 0 0 0 1 1 1 1 4 H = 0 0 0 0 0 0 0 0 1 1 1 1 pp = 4

### Community Treasure Hunt

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

Start Hunting!