Welcome to the daily solving of our PROBLEM OF THE DAY with Saksham We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.
Given an unsorted array of integers arr[], and a target tar, determine the number of subarrays whose elements sum up to the target value.
Examples:
Input: arr[] = [10, 2, -2, -20, 10] , tar = -10
Output: 3
Explanation: Subarrays with sum -10 are: [10, 2, -2, -20], [2, -2, -20, 10] and [-20, 10].
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/subarray-range-with-given-sum0128/1