Python - Replacing by Greatest Neighbour in list
Given a list, the task is to write a Python program to replace with the greatest neighbor among previous and next elements. Input : test_list = [5, 4, 2, 5, 8, 2, 1, 9], Output : [5, 5, 5, 8, 8, 8, 9, 9] Explanation : 4 is having 5 and 2 as neighbours, replaced by 5 as greater than 2. Input : test_list = [5, 4, 2, 5], Output : [5, 5, 5, 5] Explanat