请问485怎么diy,那里又模板?# EB23 - 劳工卡
g*j
1 楼
Given two sorted integer arrays A and B of size n and m respectively, find
the kth smallest element in the union of A and B in O(lg(n)+lg(m)) time....
我解法如下
找到 A 的 中间值 a, O(1), 然后在B里面找到比它小的数的个数, O(lg(m)), 两个数组中小于等于a的数字的和为t,
如果t=k, 则返回a;
如果t>k, 则丢掉所有比a大的数, 在剩下的数中间找kth smallest的
如果t 但是, 这个不是lg(n)+ lg(m)的吧?
the kth smallest element in the union of A and B in O(lg(n)+lg(m)) time....
我解法如下
找到 A 的 中间值 a, O(1), 然后在B里面找到比它小的数的个数, O(lg(m)), 两个数组中小于等于a的数字的和为t,
如果t=k, 则返回a;
如果t>k, 则丢掉所有比a大的数, 在剩下的数中间找kth smallest的
如果t