由买买提看人间百态

topics

全部话题 - 话题: bidx
(共0页)
w***o
发帖数: 109
1
来自主题: JobHunting版 - 好象是google的高频题目
这是我见过的最精简的算法,可以用java实现。复杂度是O(lg(m))比leetcode上的
还快。leetcode上的几个实现基本都是merge或merge+binary search的思想,这个是
纯binary search,核心部分只有十几行:(过了OJ)
public double findMedianSortedArrays(int A[], int B[]) {
if((A == null ||A.length == 0) && (B == null || B.length == 0))
return 0.0;

if (A.length >= B.length)
return findMedianSortedArraysInternal(B, A);
else
return findMedianSortedArraysInternal(A, B);
}

double findMedianSortedArraysInternal(i... 阅读全帖
w***o
发帖数: 109
2
来自主题: JobHunting版 - 好象是google的高频题目
这是我见过的最精简的算法,可以用java实现。复杂度是O(lg(m))比leetcode上的
还快。leetcode上的几个实现基本都是merge或merge+binary search的思想,这个是
纯binary search,核心部分只有十几行:(过了OJ)
public double findMedianSortedArrays(int A[], int B[]) {
if((A == null ||A.length == 0) && (B == null || B.length == 0))
return 0.0;

if (A.length >= B.length)
return findMedianSortedArraysInternal(B, A);
else
return findMedianSortedArraysInternal(A, B);
}

double findMedianSortedArraysInternal(i... 阅读全帖
s******n
发帖数: 3946
3
Data a[size];
...
int l=0,m=0;
for (int i=0; i if (a[i].key==0) l++;
else if (a[i].key==1) m++;
else n++;
}
int aidx = 0;
int bidx = 0;
int cidx = 0;
for (int i=0; i if (a[i].key==0) {
a[i].key = aidx++;
} else if (a[i].key==1) {
a[i].key = l + bidx++;
} else {
a[i].key = l + m + cidx++;
}
}
for (int i=0; i while (a[i].key!=i) {
int swapIdx = a[i];
Data tmp = a[swapIdx];
a[swapIdx] = a[i];
a[... 阅读全帖
f*********d
发帖数: 140
4
//上一个我见过的最精简的代码吧,实战慎用:)
//注: 非原创~
double findMedianSortedArrays(int A[], int m, int B[], int n)
{
if(m > n)
return findMedianSortedArrays(B, n, A, m);

int k = (n + m - 1) / 2;
int l = 0, r = m;
while (l < r) {
int mid = l + (r - l) / 2;
int bIdx = k - mid;
if (A[mid] < B[bIdx])
l = mid + 1;
else
r = mid;
}

int a = l - 1 >= 0 ? A[l - 1] : INT_MIN;
int b = k - l >= 0 ? B[k - l] : INT_MIN;
a = a >= b ? a : ... 阅读全帖
e****0
发帖数: 678
5
来自主题: MedicalCareer版 - [我的CK笔记]妇产科
 Screening
 Pap smear for vervical cancer is 21 yo
 DM
24-28 weeks
One hour 50 grams oral glucose tolerance test. BG > 140
Three hours glucose tolerance test (if two or more are positive)
1. Fasting BG > 95
2. One hour BG > 180
3. Two hours BG> 155
4. Three hours BG > 140
• Dysfunctional uterine bleeding (DUB)
 Heavy vaginal bleeding occurs in the absence of structural or
organic disease
 Endometrial biop... 阅读全帖
(共0页)