Count Nearly Regular Matrix Crosses
Updated
Problem statement
A cross is one complete row and one complete column of a rectangular integer matrix.
A row-column pair is nearly regular when every cross element is equal except possibly their intersection cell. A fully regular cross also qualifies.
Return the number of qualifying row-column pairs.
Function
countNearlyRegularCrosses(matrix: int[][]) → intExamples
Example 1
matrix = [[1,1],[1,2]]return = 2The crosses centered at (0,0) and (1,1) have equal non-intersection elements.
Example 2
matrix = [[7]]return = 1A one-cell cross qualifies vacuously.
Constraints
1 <= rows,columns <= 50
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Rotate Matrix Regions Around the DiagonalsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Rotate Matrix Regions Around the DiagonalsHudson River Trading · OAHudson River Trading interview questions
- Robot Navigation Around LasersRoblox · OARoblox interview questions
- Leaves Remaining After Wind GustsOpenAI · OAOpenAI interview questions
- Apply a Reversi MoveAmazon · OA
- Flip, Invert, and Smooth a Binary ImageAbridge · OAAbridge interview questions
- Count Straight-Line Word Occurrences in a GridOptiver · OAOptiver interview questions
- First Completed Mingo LineEpic · OAEpic interview questions
- Sort Every Matrix Border LayerCapital One · OACapital One interview questions
- Rotate a Square Matrix ClockwiseVisa · OAVisa interview questions