class Solution {
public:
int medianSearch(vector<int>& S1 , vector<int>& S2) {
int p = 0, q = 0;
int L = S1.size();
for (int i = 1; i <= L - 1; ++ i)
{
if (S1[p] < S2[q]) p ++;
else q ++;
}
return S1[p] < S2[q] ? S1[p] : S2[q];
}
};