Yahoo India Web Search

Search results

  1. 1 day ago · Given a 1-based indexing array arr [] of non-negative integers and an integer sum. You mainly need to return the left and right indexes (1-based indexing) of that subarray. In case of multiple subarrays, return the subarray indexes which come first on moving from left to right.

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

  3. Step 1 - Take an array from the user of ' n ' elements; which refer to the non-negative integers in the main function. We can also take the sum value from the user to generate the result accordingly. Step 2 - Make a function call to find a subarray in which the sum of all the elements matches the given sum.

  4. Sep 20, 2022 · Given an unsorted array of integers, find a subarray that adds to a given number. If there is more than one subarray with the sum of the given number, print any of them. Examples: Input: arr [] = {1, 4, 20, 3, 10, 5}, sum = 33. Output: Sum found between indexes 2 and 4. Explanation: Sum of elements between indices.

  5. Mar 18, 2024 · Overview. In this tutorial, we’ll talk about the problem of finding the number of subarrays with a given sum . First, we’ll define the problem and provide an example to explain it. Then, we’ll present two different approaches to solving it and work through their implementations and time complexity. 2. Defining the Problem.

  6. Oct 19, 2021 · Find subarrays with a given sum in an array. Given an integer array, find subarrays with a given sum in it. For example, Input: nums [] = { 3, 4, -7, 1, 3, 3, 1, -4 } target = 7. Output: Subarrays with the given sum are. { 3, 4 } { 3, 4, -7, 1, 3, 3 } { 1, 3, 3 } { 3, 3, 1 } Practice this problem.

  7. Dec 21, 2021 · Given an unsorted array of nonnegative integers, find a continuous subarray which adds to a given number. Examples : Input: arr[] = {1, 4, 20, 3, 10, 5}, sum = 33. Output: Sum found between indexes 2 and 4. Sum of elements between indices. 2 and 4 is 20 + 3 + 10 = 33. Input: arr[] = {1, 4, 0, 0, 3, 10, 5}, sum = 7.

  8. Continuous Subarray Sum - Given an integer array nums and an integer k, return true if nums has a good subarray or false otherwise. A good subarray is a subarray where: * its length is at least two, and * the sum of the elements of the subarray is a multiple of k.

  9. Minimum Size Subarray Sum - Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead.

  10. Jul 15, 2022 · Find a subarray having the given sum in an integer array. Given an integer array, find a subarray having a given sum in it. For example, Input: nums [] = {2, 6, 0, 9, 7, 3, 1, 4, 1, 10}, target = 15. Output: {6, 0, 9} Input: nums [] = {0, 5, -7, 1, -4, 7, 6, 1, 4, 1, 10}, target = 15. Output: {1, -4, 7, 6, 1, 4} or {4, 1, 10}

  1. People also search for