Google | Phone | Longest Subarray Sum at Most K
Anonymous User
13975

Hi all, got a question:
find the longest subarray whose sum is less or equal to K

int[] arr = {1, 2, 1, 0, 1, -8, -9, 0};
int k = 4;
Output is 8

int arr[] = {1, 2, 1, 0, 1, 1, 0};
int k = 4;
output is 5

could come up with a brute forse solution only, will really appriciate your help

Comments (19)