#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
bool Find(int *matrix,int rows,int colums,int number) {
int i = 0;
int j = colums-1;
if (matrix != NULL) {
while (i < rows&&j >= 0)
{
if (number == matrix[i*rows + j]) return true;
else if (number > matrix[i*rows + j]) { i++; }
else { j--; }
}
}
return false;
}
};
int main()
{
Solution s;
int p[] = { 1,2,8,9,2,4,9,12,4,7,10,13,6,8,11,15 };
int d=s.Find(p,4,4,7)==true;
cout << d << endl;
d = s.Find(p, 4, 4, 5) == true;
cout << d << endl;
return 0;
}