Company: Visa_1july
Difficulty: medium
Sum of Elements Greater Than Immediate Neighbors Problem Description You are monitoring the performance of devices in a network. Each device periodically reports its status by sending a numerical value. These values are collected in sequence in an array. Given an array of integers statusReports , your task is to find the sum of all elements in the array statusReports that are greater than their immediate neighbors. If an element is the first or last in the array, it should be compared only to its single neighbor. Return the resulting sum as an integer. Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(statusReports.length) will fit within the execution time limit. Examples Example 1: Input: statusReports = [1, 3, 2, 5, 1] Output: 8 Explanation: 3 (index 1) is greater than its neighbors 1 and 2. 5 (index 3) is greater than its neighbors 2 and 1. Sum of 3 and 5 is 8. Example 2: Input: statusReports = [1, 2] Output: 2 Exp