Skip to content

Commit 91052c5

Browse files
refactor 363
1 parent ed7ba04 commit 91052c5

File tree

1 file changed

+3
-19
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+3
-19
lines changed

src/main/java/com/fishercoder/solutions/_363.java

+3-19
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,11 @@
22

33
import java.util.TreeSet;
44

5-
/**
6-
* 363. Max Sum of Rectangle No Larger Than K
7-
*
8-
* Given a non-empty 2D matrix matrix and an integer k,
9-
* find the max sum of a rectangle in the matrix such that its sum is no larger than k.
10-
11-
Example:
12-
Given matrix = [
13-
[1, 0, 1],
14-
[0, -2, 3]
15-
]
16-
k = 2
17-
The answer is 2. Because the sum of rectangle [[0, 1], [-2, 3]] is 2 and 2 is the max number no larger than k (k = 2).
18-
19-
Note:
20-
The rectangle inside the matrix must have an area > 0.
21-
What if the number of rows is much larger than the number of columns?
22-
*/
235
public class _363 {
246
public static class Solution1 {
25-
/** reference: https://discuss.leetcode.com/topic/48854/java-binary-search-solution-time-complexity-min-m-n-2-max-m-n-log-max-m-n */
7+
/**
8+
* reference: https://discuss.leetcode.com/topic/48854/java-binary-search-solution-time-complexity-min-m-n-2-max-m-n-log-max-m-n
9+
*/
2610
public int maxSumSubmatrix(int[][] matrix, int k) {
2711
int row = matrix.length;
2812
if (row == 0) {

0 commit comments

Comments
 (0)