## Find subarrays with given sum in an array

Given an array A with length N, the task is to print all possible subarrays whose sum is equals to a given number "sum".

- Home
- DS & Algorithms
- DS & Algorithms

In this section we will get in depth knowledge of Array Data Structure, including Array interview questions with solution and Array based logical problems.

We will also look into time and space complexity of different algorithms and problems based on Arrays.

These Array based data structures and algorithms questions with complete explanation and implementation in Java are very helpful in cracking any software engineering interview.

Given an array A with length N, the task is to print all possible subarrays whose sum is equals to a given number "sum".

Find index that divides an array into two subarrays of equal sum, The task is to find the index that divides the array into two subarrays of equal sum. If the array can not be divided in equal sum the method should return -1

Given an array A with length n, the task is to find duplicates within a given range k in the array. We can solve this problem in O(n) time using O(n) extra space.

Given two sorted arrays, A1, A2 the task is to merge them in a sorted manner. We can solve this problem in O(n1+n2) time and O(n1+n2) extra space.

Given an array arr[] with length n, the task is to rearrange the array is such a way so that the output array should contain all the negative elements in the starting of the array followed by all positive integers.

Given an array arr[] of length n, the task is to find the contiguous subarray within the array which has the largest sum. We can solve this problem in O(n) time complexity using Kadane's Algorithm.

In and Activity Selection Problem we are given a set of activities with their start and finish time, the task is to find out the maximum number of activities completed by a single person.

In this article we will see how to left rotate an array by k elements using extra space O(k) and in O(n) time complexity, lets assume the given array is: Input: int [] arr = {1,2,3,4,5,6,7};

In this article we will see how to left rotate an array by k elements using constant space space O(1) and in O(k*n) time complexity, lets assume the given array is:

Input: int [] arr = {1,2,3,4,5,6,7};

k=3

Output: int [] arr = {4,5,6,7,1,2,3};

In this article we will see how to left rotate an array by k elements using reversal algorithm, it takes constant space space O(1) and in O(n) time complexity

In this article we will solve a problem where we need to place elements in an array in their matching indexes, in case a matching element is not available for the index, -1 will be placed there.

In this article we will see how to reverse an array using both iterative and recursive method, lets assume we have an array as shown below:

Lets assume we have given an array as shown below, the task is to move all zero elements to the end of array while non zero elements to the left of them.

In this article we will see how to rearrange an array to store elements in max, min order, lets assume we have an array as shown below:

Today we will see how to find all pair of elements in an array whose sum is equals to a given number, lets assume we are given an input array as: