any solution based on binary search?
user913
@user913
Posts made by user913

What does this topic to do with binary search?

RE: O(1) time c++ solution inspired by Q_rsqrt
Thanks above:
The following code is the fast inverse square root implementation from Quake III Arena, stripped of C preprocessor directives, but including the exact original comment text:[5]
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df  ( i >> 1 ); // what the fuck? y = * ( float * ) &i; y = y * ( threehalfs  ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs  ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}

RE: Can leetcode share top performing solution(s) of problems for each supported language ?
@jdrogin Agree. Since it is an algorithm website, could we at least have a reliable runtime?

RE: Get random int are not in a particular array
Oh, I forgot to check array.length >= n. If so it should return null.

RE: Get random int are not in a particular array
int getSpecialRandom(int n, int[] array){ Arrays.sort(array); int left, right, hashIndex; HashMap hashMap = new HashMap(); right = 0; hashIndex = 0; for(left = 0; left < n; ++left) { if (left == array[right]) ++right; else hashMap.put(hashIndex++, left); } Random ran = new Random(); return (int) hashMap.get(ran.nextInt(n  array.length)); }

RE: The expected times to get all colours, no one knows how to hack this?
@LHearen It is a FREAKING HARD problem.
It is called COUPON COLLECT PROBLEM WITH DIFFERENT PROBABILITIES.
Check this article if you want:

RE: Get random int are not in a particular array
@needCoffee Thanks, now its more clear :) my first thought, is to build a hashmap, with key: [0, N  ParticularArray.length()) (ParticularArray has no duplicates?), value: all the numbers not in ParticularArray. After this it is O(1) to getSpecialRandom().
To build the hashmap, first sort ParticularArray low to high, which is log(length)*length.
Then build 2 pointers, A from 1~N, B from left of ParticularArray to right. which is N.

RE: 2 sorted integer arrays,Find the Kth smallest distinct sum.[1,2,4,6] and [2,3,5,8,10] with K == 3, the answer is 5
@jeantimex prove that you can produce all the unions?

RE: Share my java AC solution.
@Hank2016 same error: Submission Result: Time Limit Exceeded More Details
Last executed input:
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...,9]
5