I'm writing a simple program to search for an element in a 2D matrix. It's not giving me an active/named exception, but it just throws me a Runtime error.
Any help with as to why this is happening?
class Solution {
public:
    bool searchMatrix(vector<vector<int>>& matrix, int target) {
        for (int i=0 ;i< matrix.size(); ++i){
            int m = matrix[i].size() -1 ;
            int n = matrix.size()-1;
            if (matrix[n][m] < target){
                return false;
            }
            else if (matrix[i][m] < target){
                i++;
            } else {
                 for (int j=0;j <= m; j++ ){
                    if (matrix[i][j] == target){
                        return true;
                    } else if (matrix[i][j] != target) {
                        continue;
                    }
                }
                
                 if (matrix[i][m] != target ){
                    return false;
                }
            }      
        }throw; 
    }
};
 
     
    