Submitted Questions

  • Marbles and Floors

    You have a 100-story building and a couple of marbles. You must identify thelowest floor for which a marble will break if you drop it from this floor. How fastcan you find this floor if you are given an infinite supply of marbles? What if youhave only two marbles?

    Tyler

    • May 20th, 2015

    Start at floor 10. If the marble breaks start at 1. If it Doesnt go to 20: repeat for 11-19, and Repeat the process for 30,40,... to 100. Max amount of Drops will be 19: at 91. Up all the way to 100(10 drops) and 9 floors down(9 drops)

    lily

    • Apr 15th, 2015

    With 2 marbles: Go to floor 50. If the marble breaks, go to floor 1 then floor 2 and so on up to floor 49 or until your marble breaks. Then the solution is the previous floor. If the marble doe...

  • Sorted Matrix

    You are given a matrix. The matrix elements are such that they are sorted both horizontally and vertically. Given an element of the matrix, your job is to obtain its position in an efficient manner.Example: 10 20 30 15 35 98 48 76 110Input: 76Output: 3rd row, 2nd column.

    sandy

    • Mar 24th, 2013

    I assume you can do it in the following way: "python class Coordinate: def __init__(self,x=0,y=0): self.x = x self.y = y def findElement(a,n): if a == Non...

  • Duplicate Elements Array

    You have an array of size '2n' of these, 'n+1' elements are distinct and 1 element is repeated 'n' times. You must find the repeated element and say how many times it has repeated. Your solution must use minimum no. of comparisons. Also, say how many comparisons your solution will make in the worst case?

    shankar

    • Oct 16th, 2012

    Since an element is repeated more than half the occurance of the array, for every two didtinct elements discard them from the array. At the end of the loop, the most repeated element will be left.

    This is O(n)

  • sub matrix

    u are given a n*n square matrix where each element is either 0 or 1....u have to find the square submatrix with the largest length such that all the elements along the border of that square submatrix matrix is 1 ....