mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-09-20 07:43:04 +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 i = 0;
|
||||
|
||||
while (comparator.notEqual(i, array.length - 1))
|
||||
{
|
||||
while(comparator.notEqual(array[i], seekElement))
|
||||
{
|
||||
while (comparator.notEqual(i, array.length - 1)) {
|
||||
while(comparator.notEqual(array[i], seekElement)) {
|
||||
i = i + 1;
|
||||
}
|
||||
if(comparator.notEqual(i, array.length - 1))
|
||||
{
|
||||
if(comparator.notEqual(i, array.length - 1)) {
|
||||
foundIndices.push(i);
|
||||
i = i + 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user