Sum Every Third Spiral Element
Updated
Problem statement
Traverse a square integer matrix in clockwise spiral order starting at the top-left. Return the sum of elements at zero-based spiral indices divisible by three.
Function
sumEveryThirdSpiral(matrix: int[][]) → longExamples
Example 1
matrix = [[1,2,3],[4,5,6],[7,8,9]]return = 14The selected spiral values are 1, 6, and 7.
Example 2
matrix = [[5]]return = 5The only value has spiral index zero.
Constraints
1 <= matrix.length == matrix[i].length <= 500
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