Category Archives: Arrays

Questions regarding Arrays

Check if two arrays are equal or not

Given two given arrays of equal length, the task is to find if given arrays are equal or not. Two arrays are said to be equal if both of them contain same set of elements, arrangements (or permutation) of elements may be different though. Note : If there are repetitions, then counts of repeated elements… Read More »

Count passing car pairs

A non-empty binary array A consisting of size N is given where, 0 represents a car traveling east, 1 represents a car traveling west. The goal is to count passing cars. We say that a pair of cars (P, Q), where 0

Find floor and ceil in an unsorted array

Given an unsorted array arr[] and an element x, find floor and ceiling of x in arr[0..n-1]. Floor of x is the largest element which is smaller than or equal to x. Floor of x doesn’t exist if x is smaller than smallest element of arr[]. Ceil of x is the smallest element which is… Read More »

Type of array and its maximum element

Given an array, it can be of 4 types (a) Ascending (b) Descending (c) Ascending Rotated (d) Descending Rotated Find out which kind of array it is and return the maximum of that array. Examples: Input : arr[] = { 2, 1, 5, 4, 3} Output : Descending rotated with maximum element 5 Input :… Read More »