Yahoo India Web Search

Search results

  1. Can you solve this real interview question? Subarray Sum Equals K - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

  2. Mar 31, 2023 · Given an unsorted array of integers, find the number of subarrays having a sum exactly equal to a given number k. Examples: Input : arr [] = {10, 2, -2, -20, 10}, k = -10. Output : 3. Explanation: Subarrays: arr [0…3], arr [1…4], arr [3..4] have a sum exactly equal to -10. Input : arr [] = {9, 4, 20, 3, 10, 5}, k = 33. Output : 2.

  3. Oct 14, 2020 · In this article, we will learn to resolve the Subarray Sum Equals K problems by using Brute force, Sliding window, and Hash table algorithms. Problem 1. Given an unsorted array of non-negative integers a[n] and an integer k. Find a continuous sub array whose sum equals to k. Example 1.1. Input: a = [4, 0, 11, 6, 1, 7] and k = 8. Output: [1, 7]

  4. Given an unsorted array of integers, find the number of continuous subarrays having sum exactly equal to a given number k. Example 1: Input: N = 5. Arr = {10 , 2, -2, -20, 10} k = -10. Output: 3. Explaination: . Subarrays: arr[0...3], arr[1...4], arr.

  5. 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.

  6. Mar 18, 2024 · The main idea in this approach is to check for each possible subarray if its sum is equal to , or not. Initially, we’ll go through every possible start of a subarray. Then, we’ll fix it for each start and try all the possible ends.

  7. Jun 20, 2024 · Last Updated : 20 Jun, 2024. Given an array arr [] of non-negative integers and an integer sum, find a subarray that adds up to the given sum. There may be more than one subarray with the sum equal to the given sum, but you need to print the first such subarray. Examples:

  1. People also search for