leetcode/include/s0004_median_of_two_sorted_...

29 lines
786 B
C++

#ifndef S0004_MEDIAN_OF_TWO_SORTED_ARRAYS_HPP
#define S0004_MEDIAN_OF_TWO_SORTED_ARRAYS_HPP
#include <vector>
using namespace std;
class S0004 {
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