Skip navigation

The old well-known(?) puzzle

Suppose we have two sorted arrays: A and B of size n.
We would like to know if there is such a pair of indexes (i,j) that A[i] + B[j] = C.
C is a given number.
What’s the best worst-case time complexity (Big Oh) of the algorithm to solve the problem?

Two ball weighing puzzles

Probably, you already know the first one. It sounds like this:
You have eight balls all of the same size. Seven of them weigh the same, and one of them weighs slightly more. How can you find the ball that is heavier by using a balance and only two weighings?
Finding the answer isn’t hard. Another [...]