27 lines
759 B
C++
27 lines
759 B
C++
|
#ifndef S0004_MEDIAN_OF_TWO_SORTED_ARRAYS
|
||
|
#define S0004_MEDIAN_OF_TWO_SORTED_ARRAYS
|
||
|
|
||
|
#include <vector>
|
||
|
|
||
|
class Solution {
|
||
|
public:
|
||
|
/**
|
||
|
* @brief Median of Two Sorted Arrays
|
||
|
*
|
||
|
* Given two sorted arrays `nums1` and `nums2` of size `m` and `n`
|
||
|
* respectively, return the median of the two sorted arrays.
|
||
|
*
|
||
|
* The overall run time complexity should be `O(log(m+n))`.
|
||
|
*
|
||
|
* @param nums1 the first sorted array
|
||
|
* @param nums2 the second sorted array
|
||
|
* @return the median of the two sorted arrays
|
||
|
*/
|
||
|
double findMedianSortedArrays(std::vector<int>& nums1,
|
||
|
std::vector<int>& nums2);
|
||
|
int getKthElement(const std::vector<int>& nums1,
|
||
|
const std::vector<int>& nums2, int k);
|
||
|
};
|
||
|
|
||
|
#endif
|