@1337c0d3r this is bulls and cows implemented with pegs.One player think a number from 1111 to 6666,because colours are 6 with 4 pegs.The other try to guess it with up to 12 tryings.The only feedback is row of 4 digits where each digit is 0 or 1 meaning that 0 is a cow and 1 is a bull.Bull means that you discovered a digit on its position.Cow meana that you have discovered digit but it isn't on its correct position First write bulls then cows.Game ends either when you receive feedback 1111 or when you guess 12 times
"You are given an array of points where each point has X and Y values. Find the midpoint of two points which exist in array in constant time."
I don't understand the question.
Are you given two points from the array and you need to compute the midpoint (very easy, constant time)?
Or do you have to verify that the midpoint is in the array (precompute a hash table of the points so you can determine if a point is in the array in O(1) time)?
Or do you want to find the point in the array that is closest to a computed midpoint of two points (not a midpoint problem, just a problem of searching array of points. Should be solved by sorting with O(nlog n) precomputation, and look up in O(log n))?