/*
思路:从右上角开始找
if(curr == target) {
    return true;
} else if (target < curr) {
    line--;
} else {
    column++;
}
*/
class Solution {
public:
    bool Find(int target, vector<vector<int> > array) {
        int column = array.size(), line = array[0].size();
        int columnIndex = 0, lineIndex = line - 1;
        while ((columnIndex >= 0 && columnIndex < column) && (lineIndex >=0 && lineIndex < line)) {
            if (array[columnIndex][lineIndex] == target) {
                return true;
            } else if (array[columnIndex][lineIndex] > target) {
                  lineIndex--;
            } else {
                  columnIndex++;
            }
        }
        return false;
        
    }
};