(A, B, reverse)
| 71 | const COMMON = 2; |
| 72 | const ADDED = 3; |
| 73 | function createCommon(A, B, reverse) { |
| 74 | const common = []; |
| 75 | if (A.length === 0 || B.length === 0) return []; |
| 76 | for(let i = 0; i < Math.min(A.length, B.length); i += 1){ |
| 77 | if (A[reverse ? A.length - i - 1 : i] === B[reverse ? B.length - i - 1 : i]) { |
| 78 | common.push(A[reverse ? A.length - i - 1 : i]); |
| 79 | } else { |
| 80 | return common; |
| 81 | } |
| 82 | } |
| 83 | return common; |
| 84 | } |
| 85 | function diff(A, B) { |
| 86 | const prefixCommon = createCommon(A, B); |
| 87 | const suffixCommon = createCommon(A.slice(prefixCommon.length), B.slice(prefixCommon.length), true).reverse(); |
no outgoing calls
no test coverage detected
searching dependent graphs…