Max Submatrix Sum in 3D Matrix
Hard
3d-matrix
submatrix-sum
dynamic-programming
optimization
Problem Description
Find the maximum sum of any rectangular submatrix in a 3D matrix. Consider all possible 3D rectangular regions and return the maximum sum.
Input Format
First line: x y z (dimensions). Next x*y lines: z space-separated integers for each layer.
Output Format
Maximum sum of any 3D rectangular submatrix.
Constraints
• 1 ≤ x, y, z ≤ 20
• -100 ≤ matrix elements ≤ 100
• Consider all possible 3D rectangular regions
• Submatrix can be any size from 1×1×1 to x×y×z
• Use efficient algorithm for large search space
Sample Input/Output
Input:
2 2 2 1 2 3 4 -1 0 1 -2
Output:
10
Explanation
Maximum sum submatrix includes elements that sum to maximum value across all possible 3D rectangular regions.
Solution Hints
150
Points
Points
4000ms
Time Limit
Time Limit
512MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now