mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Update sentinalLinearSearch.js
Test case fix
This commit is contained in:
parent
408b0fc5df
commit
7e454924de
@ -14,14 +14,11 @@ export default function sentinalLinearSearch(array, seekElement, comparatorCallb
|
|||||||
const lastEle = array[array.length - 1]; // Picking the last element in the array
|
const lastEle = array[array.length - 1]; // Picking the last element in the array
|
||||||
const i = 0;
|
const i = 0;
|
||||||
|
|
||||||
while (comparator.notEqual(i, array.length - 1))
|
while (comparator.notEqual(i, array.length - 1)) {
|
||||||
{
|
while(comparator.notEqual(array[i], seekElement)) {
|
||||||
while(comparator.notEqual(array[i], seekElement))
|
|
||||||
{
|
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
if(comparator.notEqual(i, array.length - 1))
|
if(comparator.notEqual(i, array.length - 1)) {
|
||||||
{
|
|
||||||
foundIndices.push(i);
|
foundIndices.push(i);
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user