[LeetCode]004.Median of Two Sorted Arrays

Question

There are two sorted arrays nums1 and nums2 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)).

Solution

  • C
1
2
3
double findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size) {

}
  • C++
1
2
3
4
5
6
class Solution {
public:
double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {

}
};
  • Java
1
2
3
4
5
public class Solution {
public double findMedianSortedArrays(int[] nums1, int[] nums2) {

}
}
  • JavaScript
1
2
3
4
5
6
7
8
/**
* @param {number[]} nums1
* @param {number[]} nums2
* @return {number}
*/
var findMedianSortedArrays = function(nums1, nums2) {

};
  • Python
1
2
3
4
5
class Solution:
# @param {integer[]} nums1
# @param {integer[]} nums2
# @return {float}
def findMedianSortedArrays(self, nums1, nums2):
  • Swift
1
Hello World
坚持原创技术分享,您的支持将鼓励我继续创作!