# Array

## Maximum sum in contiguous subarray

This is very famous interview question. Given an array A of integers (both positive and negative) and you need to find the maximum sum found in any contiguous subarray of A. Example A = [11, -12, 15, -3, 8, -9, 1, 8, 10, -2] Answer is 30. There are many solutions to this problem. Method Read More →

## Quick Sort

QuickSort is based on divide-and-conquer approach. QuickSort is inplace sorting algorithm.A sorting algorithm is said to be in-place if it requires very little additional space besides the initial array holding the elements that are to be sorted. The key to the Algorithm is the Partition Procedure, which rearranges the subarray a[p..r] in place. Partition selects Read More →

## Shifting zeros to end in an array

Given an array with sorted numbers and zeros in between them, than how could we rearrange the array such that all the zeros are placed at end in O(1) space complexity. ex: I/p: 3 0 0 4 0 5 0 6 7 8 0 0 9 o/p: 3 4 5 6 7 8 9 0 Read More →

## Write code to remove duplicates in a sorted array

In this simple C program, we change the original array and also send the new size of the array back to the caller. Method 1 And here is the output… OLD : [1] [1] [2] [3] [5] [6] [6] [7] [10] [25] [100] [123] [123] NEW : [1] [2] [3] [5] [6] [7] [10] [25] [100] [123] Method 2 If we dont want to change the input array and just want to print the array without any duplicates, the solution is very Read More →