PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Capital One

Implement 2D transforms and find max-lit point

Last updated: Mar 29, 2026

Quick Overview

This question evaluates array-manipulation and interval-analysis skills, specifically in-place 2D matrix transformations (row/column swaps, reversals, rotations) and determining the point with maximum overlap among one-dimensional illumination intervals.

  • Medium
  • Capital One
  • Coding & Algorithms
  • Software Engineer

Implement 2D transforms and find max-lit point

Company: Capital One

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

Part A — 2D array transforms: Given an m×n integer matrix, implement the following in-place operations with clear function boundaries and complexity: ( 1) swapRows(A, i, j) that swaps two row indices i and j; ( 2) swapCols(A, i, j) that swaps two column indices i and j; ( 3) reverseRowOrder(A) that reverses the order of rows (top↔bottom) and reverseColOrder(A) that reverses the order of columns (left↔right); ( 4) rotate90(A, direction) that rotates the matrix by 90 degrees in the specified direction (clockwise or counterclockwise), supporting both square and rectangular matrices (for rectangular, return a new matrix or explain constraints). Specify time and space complexities and any edge-case handling (e.g., empty matrix, single row/column). Part B — most-illuminated point: You are given a list of street lights as pairs (x, r) where x is the light’s coordinate on a 1D line and r is its illumination radius. Each light illuminates the interval [x − r, x + r]. Find the point on the line covered by the maximum number of lights; if multiple points achieve the same maximum coverage, return the smallest such coordinate. Describe and implement an algorithm with optimal time complexity, and analyze time and space.

Quick Answer: This question evaluates array-manipulation and interval-analysis skills, specifically in-place 2D matrix transformations (row/column swaps, reversals, rotations) and determining the point with maximum overlap among one-dimensional illumination intervals.

Related Interview Questions

  • Solve Four Coding Assessment Tasks - Capital One (medium)
  • Write SQL using joins and window functions - Capital One (medium)
  • Review Preprocessing Code and Tests - Capital One (easy)
  • Remove nodes with a given value - Capital One (medium)
  • Solve multiple algorithmic interview questions - Capital One (hard)
Capital One logo
Capital One
Sep 6, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
3
0

Part A — 2D array transforms: Given an m×n integer matrix, implement the following in-place operations with clear function boundaries and complexity: (

  1. swapRows(A, i, j) that swaps two row indices i and j; (
  2. swapCols(A, i, j) that swaps two column indices i and j; (
  3. reverseRowOrder(A) that reverses the order of rows (top↔bottom) and reverseColOrder(A) that reverses the order of columns (left↔right); (
  4. rotate90(A, direction) that rotates the matrix by 90 degrees in the specified direction (clockwise or counterclockwise), supporting both square and rectangular matrices (for rectangular, return a new matrix or explain constraints). Specify time and space complexities and any edge-case handling (e.g., empty matrix, single row/column). Part B — most-illuminated point: You are given a list of street lights as pairs (x, r) where x is the light’s coordinate on a 1D line and r is its illumination radius. Each light illuminates the interval [x − r, x + r]. Find the point on the line covered by the maximum number of lights; if multiple points achieve the same maximum coverage, return the smallest such coordinate. Describe and implement an algorithm with optimal time complexity, and analyze time and space.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Capital One•More Software Engineer•Capital One Software Engineer•Capital One Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.