Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let arr = gets().split('').map(Number);
- // console.log(arr)
- let target = +gets();
- let result = [];
- for(let i = 0; i < arr.length; i++){
- let currentN = arr[i];
- let prevN = arr[i - 1];
- let nextN = arr[i + 1];
- if(currentN === target){
- if(currentN !== prevN && currentN !== nextN){
- currentN = Math.max(prevN, nextN)
- }
- result.push(prevN, currentN, nextN)
- }
- }
- console.log(result.join());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement