FastPrepFind Last Cell
Problems/Find Last Cell

Find Last Cell

Cisco logoCisco● MediumINTERNNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Special thanks: Charlotte shared this problem.

Lucy loves to play the Hop, Skip and Jump game on a matrix. She starts at the top-left cell and walks through every cell in an anti-clockwise spiral:

  1. down the leftmost column,
  2. right along the bottom row,
  3. up the rightmost column,
  4. left along the top row,
  5. then the same around the next ring inside, until every cell has been visited once.

Along this walk she hops onto the first cell, skips the next one, hops onto the one after, and keeps alternating. Return the value in the last cell she hops onto.

Function

findLastCell(matrix: int[][]) → int

Examples

Example 1

matrix = [[29, 8, 37], [15, 41, 3], [1, 10, 14]]return = 41
matrix
012029837115413211014

Lucy starts with 29, skips 15, hops onto 1, skip 10, hops onto 14, skips 3, hops onto 37, skips 8 and finally hops onto 41. So, the output is 41.

Constraints

  • 1 ≤ matrix.length ≤ 100
  • 1 ≤ matrix[i].length ≤ 100, and all rows have the same length.
  • 0 ≤ matrix[i][j] ≤ 10^9

More Cisco interview questions

  • Check if a String Is a PalindromePHONE SCREEN · Seen Nov 2026
  • Find Unique ElementsPHONE SCREEN · Seen Nov 2026
  • First Letter to Appear TwicePHONE SCREEN · Seen Nov 2026
  • Middle of a Linked ListPHONE SCREEN · Seen Nov 2026
  • Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
  • Reverse a StringPHONE SCREEN · Seen Nov 2026
  • Valid ParenthesesPHONE SCREEN · Seen Nov 2026
  • K-Step Bit Flip with RetentionPHONE SCREEN · Seen Nov 2026
  • Todo Task Manager OperationsONSITE INTERVIEW · Seen Oct 2026
  • Find the Duplicate Number Without Modifying the ArrayONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Simulate Orchard Rot SpreadAirbnb · OAAirbnb interview questions
  • Simulate Orchard Rot SpreadCapital One · OACapital One interview questions
  • 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
All Cisco interview questionsSee Cisco hiring insights
Saved
class Solution {
    public int findLastCell(int[][] matrix) {
      // write your code here
    }

}
Checking account…