In Canva's design editor, a sequence of integers represents the estimated render-cost change for consecutive elements. Given nums and a budget k, return the length of the longest non-empty contiguous subarray whose sum is less than or equal to k.
Values may be negative, so a standard sliding-window approach is not valid. Design an algorithm that handles arbitrary integers efficiently.
Implement longest_subarray_at_most_k(nums, k).
nums, a list of integers, and k, an integer.k.nums is empty, return 0.def longest_subarray_at_most_k(nums, k):