CODING
SYSTEM DESIGN
PLACEMENT PREP.
BLOG
LOGIN/REGISTER
MY ACCOUNT
LOGOUT
Majority Element of an Array (Moore's Algorithm)
An integer x in array arr of n elements is the majority element if and only if x appears more than n/2 times in A.
[…]
Print array in the forward and backward direction recursively
Write a recursive function which will print an array in forward and backward order (depending on a parameter). The signature of the function should be
[…]
Find kth element in union of two arrays
Given two sorted arrays of size m and n respectively. Find the kth element in the merged result of A and B. For example, If the inputs (A, B
[…]
Missing and repeating number in an array
Given an unsorted array of size n with numbers ranging from 1 to n. One number from set {1, 2, 3, …, n} is missing
[…]
Continuous sub-array with given sum
Given an array of positive integers and a number ‘k’. Find continuous subarray whith sum of all the elements = k. For example.. Array k
[…]
Merge two arrays into one
There are 2 sorted arrays of size m and m+n respectively. First array (of size m) has m elements and Second array (of size m+n)
[…]
Number of inversions in an Array.
Write a function which will accept an array and count the number of inversions in the array. Inversions in an Array are a measure of
[…]
Freeing memory allocated to n-dim array using free
Yesterday we learned about how to allocate memory on heap for an n-dim array using Malloc. Today let us see how to deallocate the memory
[…]
Allocating memory to n-dim Array on heap
Dynamic arrays are on heap. If an array is stored on heap, its address must be stored in pointer variables, else there will be no
[…]
Search in a matrix sorted on rows & columns
Given a matrix whose each row and column is sorted as shown below 10 20 30 40 15 25 35 45 27 29 37 48
[…]
Load more