NeetCode #900LC-840MediumMath & Geometry
← Back to All Problems#900 · #840 · Magic Squares In Grid(矩阵中的幻方)
📌 Problem Statement & Constraints
A 3x3 magic square contains each of the integers
1 to 9 exactly once, and every row, every column and both diagonals sum to the same value. Given a row x col grid of integers, return the number of 3x3 subgrids that are magic squares. Constraints: 1 <= row, col <= 10, 0 <= grid[i][j] <= 15.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!