Opening your workspace…
Workspace/Coding room
Opening your workspace…
A lanternfish swims through the dark ocean. Given its depth at each moment and the deepest depth reached by sunlight, find the longest consecutive stretch of moments it spends below the sunlight.
[12,25,30,18,8,14], 15Output3The fish is below sunlight for three consecutive moments at depths 25, 30, and 18.
[4,9,11,7], 20Output0Every recorded depth is within the reach of sunlight.
Reset the current streak whenever the sun reaches the swimmer.
function solve(depths, sunlight_limit) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.