leetle

Daily challenge for 2025-08-18

230. Noise Cancellation Filter

Write a function solve that removes noise spikes from audio data. Given an array of signal values and a threshold, replace any value that differs from its neighbors' average by more than the threshold with the average of its neighbors.

Example:
Input: signal = [1, 2, 10, 3, 4], threshold = 5
Output: [1, 2, 2.5, 3, 4] (10 is noise, replaced with (2+3)/2)

Run this challenge interactively in Python or JavaScript when the app loads.