7 hours ago

const solve = (intArray, sequence) => {
return intArray.join("").includes(sequence.join(""));
};

Very cheeky!!

a month ago

This solution deals with duplication in intArray as well. solve([3,3,4], [3,4]) // true

const solve = (intArray, sequence) => {
sequenceFound = false;
for (let arrIndex = 0; arrIndex < intArray.length; arrIndex++) {
if (intArray[arrIndex] === sequence) {
sequenceFound = true;
for (let sIndex = 1; sIndex < sequence.length; sIndex++) {
if (sequence[sIndex] !== intArray[arrIndex + sIndex]) {
sequenceFound = false;
break;
}
}
}
if (sequenceFound) {
break;
}
}
return sequenceFound;
};

3 months ago

const solve = (intArray, sequence) => {

const allIndexes = intArray.reduce((acc, el, i) => (el === sequence ? [...acc, i] : acc), []);
if (!allIndexes.length) return [];

for(let index = 0; index < allIndexes.length; index++) {
const firstIndex = allIndexes[index];
const seq = intArray.slice(firstIndex, sequence.length + firstIndex);

const seqFound = seq.every((_, i, self) => self[i] === sequence[i])
if (seqFound) return true;
}

return false
};

3 months ago

const solve = (intArray, sequence) => {
let isSeq = false;
for (let i = sequence.length-1; i < intArray.length; i++) {
let idxSeq = 0;
const seq = [];
for (let j = i-(sequence.length-1); j <= i; j++) {
if (intArray[j] === sequence[idxSeq]) {
seq.push(intArray[j]);
}
idxSeq++;
}
if (seq.length === sequence.length) {
isSeq = true
}
}
return isSeq;
};

3 months ago

const solve = (intArray, sequence) => { let isSeq = false; for (let i = sequence.length-1; i < intArray.length; i++) { let idxSeq = 0; const seq = []; for (let j = i-(sequence.length-1); j <= i; j++) { if (intArray[j] === sequence[idxSeq]) { seq.push(intArray[j]); } idxSeq++; } if (seq.length === sequence.length) { isSeq = true } } return isSeq; };

5 months ago

const solve = (intArray, sequence) => {
const k = sequence
const index = intArray.indexOf(k);
const subArray = intArray.splice(index, sequence.length)
let response = true;
for(let i = 0 ; i < subArray.length; i++){
subArray[i] !== sequence[i] ? response = false : response
}
return response;
};

7 months ago

`const solve = (intArray, sequence) => { let i = 0; let j = 0;

while (i < intArray.length) {
if (intArray[i] === sequence[j]) {
j++;
} else {
j = 0;
}
i++
if (j === sequence.length) return true
}
return false

};`

8 months ago

const solve = (intArray, sequence) => { const arr = intArray.join(""); const seq = sequence.join(""); return arr.includes(seq); };

8 months ago

A dirty solution, but still workng :D

const solve = (intArray, sequence) => { return !!intArray.join().match(sequence.join()) };

8 months ago

const solve = (arr1, arr2) => {
let i = 0
let j = 0
let count = 0
while(i < arr1.length) {
if (arr1[i] === arr2[j]) {
count++;
j++;
} else {
count = 0;
j = 0;
}
i++;
if(count === arr2.length) return true;
}
return false;
};

9 months ago

const solve = (intArray, sequence) => { return intArray.filter(boolean => intArray.includes(sequence)); };

2 months ago

Are you sure about it's working?

10 months ago

const solve = (intArray, sequence) => {
let index = -1;
return sequence.reduce((prev, seq) => {
const currIndex = intArray.indexOf(seq)
prev = currIndex > -1 && (currIndex-1 === index || index === -1);
index = currIndex;
return prev;
}, false)
};

a year ago

const solve = (intArray, sequence) => {
let res
for(let i = 1; i<sequence.length; i++){
if(intArray.indexOf(sequence[i]) - intArray.indexOf(sequence[i-1]) == 1){
res = true
}else{
return false
}
}
return res
};

2 years ago

const solve = (intArray, sequence) => {
return intArray.join('').includes(sequence.join(''))
};

a year ago

If the intArray is joined on a comma, the sequence array can be passed to include() as is. Don't know exactly why:

const solve = (intArray, sequence) => {
return intArray.join().includes(sequence);
};

2 years ago

const solve = (intArray, sequence) => { return intArray.toString().includes(sequence.toString()) };

2 years ago

const solve = (intArray, sequence) => { const [str1,str2 ] = [intArray.join(""), sequence.join("")] return str1.includes(str2) };

2 years ago

intArray.join("").split(sequence.join("")).length==2;