Java - Divide and Conquer approach
Find the middle element in matrix. Divide matrix to 4 parts:\n\nPart 1 | Part 2\n.........O..........\nPart 3 | Part4\n\nO - is the middle element.\n\nIf target
Find the middle element in matrix. Divide matrix to 4 parts:\n\nPart 1 | Part 2\n.........O..........\nPart 3 | Part4\n\nO - is the middle element.\n\nIf target is more than O - then we ignore Part1 otherwise we ignore Part 3 - and continue recursively to search in parts, to simplify code and speed up execution time - I merge neighbor parts.\n\n```\n    public boolean searchMatrix(int[][] matrix, int target) {\n        final int m = matrix.length;\n        if (m == 0 || matrix[0].length == 0) {\n            return false;\n        }\n        final int n = matrix[0].length;\n\n        return searchMatrix(matrix, target, 0, m - 1, 0, n - 1);\n    }\n\n    public boolean searchMatrix(int[][] matrix, int target, int rowStart, int rowEnd, int colStart, int colEnd) {\n        int rowMiddle = rowStart + (rowEnd - rowStart) / 2;\n        int colMiddle = colStart + (colEnd - colStart) / 2;\n        if (rowStart > rowEnd || colStart > colEnd) {\n            return false;\n        }\n        int valMiddle = matrix[rowMiddle][colMiddle];\n        if (target == valMiddle) {\n            return true;\n        }\n        if (target < valMiddle) {\n            return searchMatrix(matrix, target, rowStart, rowEnd, colStart, colMiddle - 1)\n                    || searchMatrix(matrix, target, rowStart, rowMiddle - 1, colMiddle, colEnd);\n        } else {\n            return searchMatrix(matrix, target, rowStart, rowEnd, colMiddle + 1, colEnd)\n                    || searchMatrix(matrix, target, rowMiddle + 1, rowEnd, colStart, colMiddle);\n        }\n    }\n```
['Divide and Conquer', 'Java']