Given two arrays A and B in ascending order with size m and n, respectively, question: find the Kth largest sum(a+b) where a in A and b in B, 1
H*1
2 楼
如果连clorox都洗不干净的,是不是就只有换马桶了?
g*s
3 楼
It is a Young Tableau. easy to find a way using max-heap in O(klogk).
respectively,
【在 f*********i 的大作中提到】 : Given two arrays A and B in ascending order with size m and n, respectively, : question: : find the Kth largest sum(a+b) where a in A and b in B, 1
e*3
4 楼
try Sno Bol. It is the best to clean up toilet.
g*k
5 楼
I dont think it is a Young Tableau where column is sorted also. and this questions seems have O(k) solution.
【在 g***s 的大作中提到】 : It is a Young Tableau. : easy to find a way using max-heap in O(klogk). : : respectively,
I also think there is O(k) solution. since O(klogk) only uses the Young- Tabeleau but the maxtrix of sum(a,b) is stonger than a Young-Tableleau. Another way for O(klogk) (not using max-heap): 1. pickup k elements from first line: 2. pickup k/2 elements from 2nd line: ... j. pickup k/j elements from jth line ... k. pickup 1 elements from kth line total number of elements is sum(1/j) < klogk. then find the kth, is O(klogk). It is still only uses the feature of Young-Tableleau, not sum-feature.
Given two arrays A and B in ascending order with size m and n, respectively, question: find the Kth largest sum(a+b) where a in A and b in B, 1
g*s
38 楼
It is a Young Tableau. easy to find a way using max-heap in O(klogk).
respectively,
【在 f*********i 的大作中提到】 : Given two arrays A and B in ascending order with size m and n, respectively, : question: : find the Kth largest sum(a+b) where a in A and b in B, 1
g*k
39 楼
I dont think it is a Young Tableau where column is sorted also. and this questions seems have O(k) solution.
【在 g***s 的大作中提到】 : It is a Young Tableau. : easy to find a way using max-heap in O(klogk). : : respectively,
I also think there is O(k) solution. since O(klogk) only uses the Young- Tabeleau but the maxtrix of sum(a,b) is stonger than a Young-Tableleau. Another way for O(klogk) (not using max-heap): 1. pickup k elements from first line: 2. pickup k/2 elements from 2nd line: ... j. pickup k/j elements from jth line ... k. pickup 1 elements from kth line total number of elements is sum(1/j) < klogk. then find the kth, is O(klogk). It is still only uses the feature of Young-Tableleau, not sum-feature.