Browsing the topic Arrays
Given an array of integers where each element represents the max number of steps that can be made forward from that element. Write a function to return the minimum number of jumps to reach the end of the array (starting from the first element).
Read More »Write a function to count number of smaller elements on right of each element in an array.
Read More »Find the maximum element in an array which is first increasing and then decreasing
19 Comments | Filed under ArraysGiven an array of integers which is initially increasing and then decreasing, find the maximum value in the array.
Read More »Given an array A[0 ... n-1] containing n positive integers, a subarray A[i ... j] is bitonic if there is a k with i < = k = A[j].
Read More »Given an array of n distinct integers sorted in ascending order, write a function that returns a Fixed Point in the array, if there is any Fixed Point present in array, else returns -1.
Read More »Given that integers are read from a data stream. Find median of elements read so for in efficient way. For simplicity assume there are no duplicates. For example, let us consider the stream 5, 15, 1, 3 … After reading 1st element of stream – 5 -> median – 5 After reading 2nd element of [...]
Read More »Given a boolean matrix mat[M][N] of size M X N, modify it such that if a matrix cell mat[i][j] is 1 (or true) then make all the cells of ith row and jth column as 1.
Read More »Given a 2D array, print it in spiral form. See the following examples.
Read More »Given an unsorted array of size n. Array elements are in range from 1 to n. One number from set {1, 2, …n} is missing and one number occurs twice in array. Find these two numbers.
Read More »Given an unsorted array arr[] and two numbers x and y, find the minimum distance between x and y in arr[].
Read More »Given two arrays: arr1[0..m-1] and arr2[0..n-1]. Find whether arr2[] is a subset of arr1[] or not. Both the arrays are not in sorted order.
Read More »Given an array and an integer k, find the maximum for each and every contiguous subarray of size k.
Read More »Given an array arr[], find the maximum j – i such that arr[j] > arr[i]
28 Comments | Filed under ArraysGiven an array arr[], find the maximum j – i such that arr[j] > arr[i].
Read More »Given a sorted array arr[] and a number x, write a function that counts the occurrences of x in arr[]. Expected time complexity is O(Logn)
Read More »Given a sorted array of n integers where each integer is in the range from 0 to m-1 and m > n.
Read More »Given an unsorted array of numbers, write a function that returns true if array consists of consecutive numbers.
Read More »Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element on the right side of x in array.
Read More »Given an n x n matrix, where every row and column is sorted in increasing order. Given a number x, how to decide whether this x is in the matrix. The designed algorithm should have linear time complexity.
Read More »Given an image, how will you turn it by 90 degrees? A vague question. Minimize the browser and try your solution before going further.
Read More »Minimizing the number of writes is useful when making writes to some huge data set is very expensive, such as with EEPROMs or Flash memory, where each write reduces the lifespan of the memory.
Read More »Difficulty Level: Rookie Both Arrays and Linked List can be used to store linear data of similar types, but they both have some advantages and disadvantages over each other.
Read More »Equilibrium index of an array is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes. For example, in an arrya A:
Read More »Given an array of n elements which contains elements from 0 to n-1, with any of these numbers appearing any number of times. Find these repeating numbers in O(n) and using only constant memory space.
Read More »Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted
21 Comments | Filed under ArraysGiven an unsorted array arr[0..n-1] of size n, find the minimum length subarray arr[s..e] such that sorting this subarray makes the whole array sorted.
Read More »Given an array A[] consisting 0s, 1s and 2s, write a function that sorts A[]. The functions should put all 0s first, then all 1s and all 2s in last.
Read More »