Median of Two Sorted Arrays (找两个序列的中位数,O(log (m+n))限制) 【面试算法leetcode】
摘要:
题目:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 题意已只两个有序的序列,找到他们的中位数,复杂度要求O(log (m+n))。 问题可以转化成两个有序序列找第num大的数,用类似二分的思想,用递归处理。因为两个序列是有序的,对比A和B第num/2个数大小,每次把小的序列删掉num/2个数,能保证不会删掉第num大 阅读全文
浙公网安备 33010602011771号