class Solution { public: int find(vector<int> a, int x) { int l = 0, r = a.size() - 1; while(l < r) { int mid = (l + r) / 2; if(x > a[mid]) l = mid + 1; else r = mid; } if(a[l] == x) return l; else return -1; } vector<int> findElement(vector<vector<int> > mat, int n, int m, int x) { // write code here vector<int> res; for(int i = 0; i < n; i++) { int left = mat[i][0], right = mat[i][m-1]; if(left <= x && x <= right) { int l = i; int r = find(mat[i], x); if(r != -1) { res.push_back(l); res.push_back(r); return res; } } if(x < left) break; } return res; } };