Затруднение с Alone Numbers - Mock exam 3

Здравейте,
Имам затруднение със задачата по-долу.
При мен работи, но в системата за оценяване не се получава. Предполагам, че входните данни влизат по друг начин от този, който аз си мисля или имам грешка, която не виждам.
Моля ви за насоки. Предварително благодаря на всички!
Моето решение:

Условие:
Alone Numbers

We will give you array and a target! You need to find all “alone” elements in the array that match the given target. These elements are alone if they have values before and after them, but those values are different from them.

Return new version of the given array where every element that matches the target and is alone is replaced by whichever value to its left or right is larger.

Input

Read from the standard input:

  • The first line is the array with coma separated integer values → 1,2,3
  • The second line is the target that you should check against → 2

Output

Print to the standard output:

  • One line of output - the changed array → [1, 3, 3]
  • please note that there is space after each coma.

A judge каква грешка дава? Wrong answer, short circuit?

И двете.

Ясно, на пърия тест ти дава грешен резултат, след това джъдж гърми, за да не може човек да си натамъни изхода, или формата на аутпута ти е грешен, или логиката на самата програма. Дава ли ти да разшириш тест 1 и да видиш какъв резултат е дало изпълнението?

Сега от телефона не мога да видя, но мисля, че ми излезе 1,2,3.

1, 3, 3 би трябвало да е, нямам достъп до самата задача.
Между 1,3,3 и 1, 3, 3 има разлика. :slight_smile:

Ще я погледна по-късно пак да я помъча, много благодаря за включването.

Здравейте , поправете си принтирането :
let input =[‘1,2,3,2,5,2’, ‘2’];
let print = this.print || console.log;
let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);

let numbers = gets().split(‘,’).map(Number);
let target =+gets();

for (let i =1;i<numbers.length-1;i++){
let prevNum =+numbers[i-1];
let currNum =+numbers[i];
let nextNum =+numbers[i+1];

if(currNum ===target && currNum !==prevNum && currNum !==nextNum){
    numbers[i]=Math.max(prevNum, nextNum);
}

}
print([${numbers.join(',')}]); :ok_hand: