Yahoo India Web Search

Search results

  1. Jun 7, 2024 · Given an array arr [] of size n containing integers. The problem is to find the length of the longest sub-array having sum equal to the given value k. Examples: Input: arr [] = { 10, 5, 2, 7, 1, 9 }, k = 15. Output: 4.

  2. Given an array arr containing n integers and an integer k. Your task is to find the length of the longest Sub-Array with the sum of the elements equal to the given value k. Examples: Input : arr[] = {10, 5, 2, 7, 1, 9}, k = 15 Output :

  3. Subarray Sum Equals K - Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. A subarray is a contiguous non-empty sequence of elements within an array.

  4. Nov 29, 2023 · Longest subarray having sum K | Set 2. Given an array arr [] of size N containing integers. The task is to find the length of the longest sub-array having sum equal to the given value K. Examples: The subarray {3, 4, 2, 1} gives summation as 10. The subarray {9, 4} gives summation as 13.

  5. Find the length of the longest subarray in which the sum of elements is equal to ‘K’. If there is no subarray whose sum is ‘K’ then you should return 0. Example: Input: ‘N’ = 5, ‘K’ = 4, ‘NUMS’ = [ 1, 2, 1, 0, 1 ] Output: 4. There are two subarrays with sum = 4, [1, 2, 1] and [2, 1, 0, 1].

  6. Find the maximum subarray sum of all the subarrays of nums that meet the following conditions: * The length of the subarray is k, and * All the elements of the subarray are distinct. Return the maximum subarray sum of all the subarrays that meet the conditions.

  7. Sep 19, 2016 · Longest Sub-array: Find the length of longest contiguous sub-array where the sum of the elements in subarray is less than or equal to "k". Inputs are: array and k. Example: Array = {1,2,3}, k = 3 Output: 2. Explanation: Sub arrays : {1},{2},{3},{1,2},{2,3},{1,2,3} {1,2} => max length = 2; 1+2 = 3 (<=k);

  8. Nov 3, 2016 · We loop through s and add every element from s to current. If the total sum of current becomes too large (larger than k ), we remove elements from the left of current until the sum is smaller than or equal to k. If at any point, the sum is equal to k, we record the length.

  9. Mar 4, 2024 · Introduction: In the algorithmic problem-solving, there lies a fascinating challenge known as the “Longest Subarray Sum Problem.” This problem entails finding the longest contiguous...

  10. medium.com › @gokulvaradan › longest-subarray-with-sum-k-90b1c2012992Longest Subarray With Sum K - Medium

    Sep 27, 2023 · Find the length of Longest Subarray whose sum is equal to given K. Problem Link: Coding Ninjas. Brute-force Approach: We have to find the subarray with sum equal to K. Let’s use...