Category Archives: Arrays

Questions regarding Arrays

Arrays in Java

An array is a container object that holds a fixed number of values of a single data type. This is different from C/C++ where array name represents an address. Length of an array is fixed when it is created (Note that we are talking about simple arrays here, not dynamic arrays like ArrayList) Since arrays… Read More »

Program to find the number of persons wearing white hat

There are N persons in a room, each of them wearing a hat which is either black or white. Every person counts the number of other persons wearing the white hat. Given the number of counts of each person, the task is to find the number of persons wearing white hats, or print -1 if… Read More »

Minimum XOR Value Pair

Given an array of integers. Find the pair in an array which has minimum XOR value. Examples: Input : arr[] = {9, 5, 3} Output : 6 All pair with xor value (9 ^ 5) => 12, (5 ^ 3) => 6 , (9 ^ 3) => 10. Minimum XOR value is 6 Input :… Read More »

Elements before which no element is bigger in array

Given an array of integers, the task is to find count of elements before which all the elements are smaller. First element is always counted as there is no other element before it. Input : arr[] = {10, 40, 23, 35, 50, 7} Output : 3 The elements are 10, 40 and 50. Input :… Read More »