X
Submit Question

Arrays  Questions

View By:

Q1 Find the path in 2 Dimensional array which has the most 1

You have a m*n size 2 Dimensional Array filled with either 0 or 1. You have to figure out the path which contains the most 1 when starting from arr[0][0]. You can only traverse down or right.

For ex: If array has values

1 1 0 1 0 1 1 0 1 0 0 1

So here the path containing max 1 is arr[0][0], arr[0][1], arr[1][1], arr[1][2], arr[1][3] and arr[2][3]

Google  |  Level - 2

Answer Write Code Visit Question Page

Q2 Number of occurrences of a number in a sorted array.

Given a sorted array, find the number of occurrences of an element in the array. Give a O(logn) time solution.

Google  |  Level - 2

Answer Write Code Visit Question Page

Q3 Sort array of 3 distinct integers

Sort an array that contains multiple occurrences of 3 integers (1,2,3).

For example input: 121221123323

output: 111122222333

Facebook  |  Level - 2

Answer Write Code Visit Question Page

Q4 Rotate an array to the left or right by a given number.

Given an array, rotate it to the left or right by a given number of steps.

Facebook  |  Level - 2

Answer Write Code Visit Question Page

Q5 Find out non repeating numbers

Given an array having numbers from 1 to N in random order such that all numbers except two are repeating twice, find out the two numbers.

Microsoft  |  Level - 3

Answer Write Code Visit Question Page

Q6 Copy sub-array within an array

Given an array, a start index, length and a dest index, copy the sub-array of given length from starting index to destination index.

Microsoft  |  Level - 2

Answer Write Code Visit Question Page

Q7 Given a sorted, shifted array find the minimum element

Given a sorted, shifted array find the minimum element. For example in 34512 the minimum is 1, in 45123 the minimum is 1.

Microsoft  |  Level - 3

Answer Write Code Visit Question Page

Q8 Find an element in a rotated sorted array.

Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). How do you find an element in the rotated array efficiently

Facebook  |  Level - 2

Answer Write Code Visit Question Page

Q9 How to manipulate a matrix with 0s and 1s?

Given a NxN matrix with 0s and 1s. now whenever you encounter a 0 make the corresponding row and column elements 0. Flip 1 to 0 and 0 remains as they are.

Example

1 0 1 1 0

0 1 1 1 0

1 1 1 1 1

1 0 1 1 1

1 1 1 1 1

results in

0 0 0 0 0

0 0 0 0 0

0 0 1 1 0

0 0 0 0 0

0 0 1 1 0

Microsoft  |  Level - 2

Answer Write Code Visit Question Page

Q10 Given sorted arrays of length n and 2n with n elements each, merge first array into second array

Given sorted arrays of length n and 2n with n elements each, merge first array into second array.

Facebook  |  Level - 2

Answer Write Code Visit Question Page