Arrays
TIPS: Algorithms on arrays can be dealt with pointers. Taking pointers one at the beginning of the array and one at the end of the array (using length of the array) will be helpful in solving array algorithms.
algorithm to remove element from an array: 1. standard way when existing order is important: traverse through the elements, once element_to_be_deleted is found, shift remaining…
algorithm to merge two sorted arrays without additional array Algorithm to merge two sorted arrays: Here we use merge sort logic…
find all pairs in an array, that sum up to particular number with best complexity: Here we discuss two possible algorithms…
finding three elements in an array whose sum is equal to a given number Here, for every element(arr[i]) that we pick, trisum-arr[i] gives us the …
find intersection of elements in two arrayscase 1: Two arrays are unsorted; Case 2: Two arrays are sorted; case 3: Two arrays are unsorted;
find group of connected 1s in a matrix Consider a two-dimensional grid of cells, each of which may be empty or filled. The filled cells that are connected form a sector…
Dynamic Programming
subsequence of array with maximum sum (Kadane’s Algorithm): This is given by Jay Kadane. Problem Statement: In a given array, find out subarray such that the sum of its elements is maximum…
Recent Comments