← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Google software engineer interview focused on matrix operations, covering symmetry checking, in-place rotation, and eigenvalue computation. The coding portion was manageable but the eigenvalue discussion got into QR iteration territory which felt like a whole separate interview.

Questions Asked (3)

Q1

Write a function to check whether a 2D matrix is symmetric, meaning M[i][j] equals M[j][i] for all valid indices.

Algorithms & Data Structures
Author's notes

Pretty clean problem once you remember to check it's square first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that symmetry requires a square matrix and then iterate only over the upper triangle (i < j) to compare M[i][j] with M[j][i]. This avoids redundant checks and demonstrates awareness of the matrix's structural constraints.

Pro tip: Mention that you can early-exit as soon as a mismatch is found, and note that for very large matrices, a cache-friendly traversal order (e.g., row-major) can improve performance.

1. Clarify assumptions

Confirm that the matrix is square (n x n) and that symmetry is defined as M[i][j] == M[j][i] for all i, j. If not square, immediately return false.

2. Choose traversal strategy

Iterate only over the upper triangle (i from 0 to n-1, j from i+1 to n-1) to avoid redundant comparisons. This halves the work and shows optimization awareness.

3. Compare and early-exit

For each pair (i, j), check if M[i][j] != M[j][i]. If any mismatch is found, return false immediately; otherwise continue.

4. Return result

After all comparisons, return true. Optionally, discuss handling edge cases like 0x0 or 1x1 matrices.

5. Analyze complexity

State that time complexity is O(n^2) in the worst case (or O(n^2/2) with upper triangle) and space complexity is O(1).

Key Points to Mention

  • Matrix must be square; otherwise, symmetry is impossible.
  • Only need to check upper triangle (i < j) to avoid redundant comparisons.
  • Early termination on first mismatch improves average-case performance.
  • Time complexity: O(n^2) worst-case, space complexity: O(1).
  • Edge cases: empty matrix (0x0) and 1x1 matrix are symmetric.
  • Cache-friendly traversal (row-major) can improve performance for large matrices.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Rotate a 2D matrix 90 degrees clockwise in place. Walk through your approach and its complexity.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Transpose then reverse each row.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., matrix is N x N, in-place required). Then present the layer-by-layer rotation approach: for each layer, rotate the four corresponding cells in a cycle. Finally, analyze time and space complexity, and discuss trade-offs with alternative approaches like transpose + reverse.

Pro tip: Mention that the transpose + reverse approach is simpler to implement but requires two passes, while the layer-by-layer approach does it in one pass; however, both are O(N^2) time. This shows you understand trade-offs beyond just correctness.

1. Clarify constraints and assumptions

Confirm that the matrix is square (N x N) and that in-place rotation is required. Ask if N can be 0 or 1, and if the matrix is mutable.

2. Explain the layer-by-layer approach

Describe how to process the matrix in concentric layers from outermost to innermost. For each layer, rotate the four edges by swapping elements in a cycle.

3. Detail the swapping logic

For each element in the top row of the current layer, perform a 4-way swap: top to right, right to bottom, bottom to left, left to top. Use a temporary variable to hold one value.

4. Analyze complexity

State that time complexity is O(N^2) because each cell is visited once. Space complexity is O(1) since rotation is done in place with only a few variables.

5. Discuss alternative and trade-offs

Mention the transpose + reverse rows method: transpose the matrix then reverse each row. It's simpler but uses two passes; still O(N^2) time and O(1) space. Compare readability vs. single-pass efficiency.

Key Points to Mention

  • In-place rotation means O(1) extra space, which is crucial for large matrices.
  • The layer-by-layer method processes each element exactly once, achieving optimal time complexity.
  • The 4-way swap cycle: temp = top; top = left; left = bottom; bottom = right; right = temp.
  • Boundary conditions: handle odd-sized matrices where the center element remains unchanged.
  • Time complexity O(N^2) is optimal because every element must be moved.
  • Trade-off: transpose+reverse is easier to code but may be less efficient in practice due to cache behavior.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

How would you compute eigenvalues for small dense matrices, and how does your approach change as matrix size grows?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where things got uncomfortable.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining the standard dense eigenvalue algorithms for small matrices, such as the QR algorithm with Hessenberg reduction, and discuss their O(n^3) complexity. Then explain how the approach shifts for larger matrices, focusing on iterative methods like Lanczos or Arnoldi that exploit sparsity and only compute a few eigenvalues. Emphasize the trade-offs between direct and iterative methods, and mention practical considerations like convergence and stability.

Pro tip: Mention that for very large matrices, you often don't need all eigenvalues—just the extremal ones—so iterative methods like Lanczos are preferred. Also, note that libraries like LAPACK and ARPACK are commonly used in practice, showing awareness of real-world implementation.

1. Clarify the problem scope

Ask whether the matrix is symmetric, dense, or sparse, and whether all eigenvalues or just a few are needed. This determines the appropriate algorithm.

2. Small dense matrices

Describe the QR algorithm: reduce to Hessenberg form, then apply QR iterations to converge to Schur form, from which eigenvalues are extracted. Mention complexity O(n^3) and that it's robust for small n.

3. Large matrices

For large n, direct methods become infeasible. Introduce iterative methods like Lanczos (symmetric) or Arnoldi (non-symmetric) that use matrix-vector products and Krylov subspaces to approximate extremal eigenvalues.

4. Trade-offs and practical considerations

Discuss convergence, memory usage, and the need for preconditioning. Mention that iterative methods may require shifts or restarts, and that libraries like ARPACK implement these.

5. Summarize and connect to software engineering

Tie back to how you would choose an approach based on constraints, and mention that in practice you'd use optimized libraries rather than implementing from scratch.

Key Points to Mention

  • QR algorithm with Hessenberg reduction for small dense matrices
  • Complexity: O(n^3) for small matrices, iterative methods for large
  • Lanczos algorithm for symmetric matrices, Arnoldi for non-symmetric
  • Krylov subspace methods and matrix-vector products
  • Trade-offs: direct vs iterative, full spectrum vs partial spectrum
  • Use of libraries like LAPACK, ARPACK, and scipy.linalg.eig

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.