Capital One OA 面經分享|2025 熱門題型復盤|Coding 思路 + 解題策略分享

1,049Views
尚無留言

這次跟大家分享一下我在 Capital One OA 裡遇到的兩道題,整體風格還是比較典型的北美銀行類大廠筆試:既考演算法思路的紮實度,又考對邏輯條件的精準把握。 第一題是摩天大樓數位裡的最大正方形面積,思路上很像「二分答案 + 區間驗證」; 第二題則是矩陣里統計“近規則十字”,重點在於對頻次分佈和中心元素特殊性的理解。 兩道題看似獨立,其實都要求寫出 clean code + 高效解法,否則很容易在時間里卡住。

Question 1: Largest Square Area

Problem:
You are given an array of integers representing the heights of skyscrapers in a row.
Find the maximum area of a square that can be placed among these buildings.

  • A square of side length m can be placed if there exists a contiguous subarray of length m where every building’s height is at least m.
  • The output should be the largest possible square area ().

Example 1:

Input: heights = [3, 1, 3, 4, 3, 5]
Output: 9
Explanation:
The maximum square has side length 3 (for example, subarray [3,4,3] or [4,3,5]).
Area = 3 * 3 = 9.

Example 2:

Input: heights = [2, 2, 2]
Output: 4
Explanation:
The maximum square has side length 2 (subarray [2,2]).
Area = 2 * 2 = 4.

Question 2: Count of Nearly-Regular Crosses

Problem:
You are given a 2D integer matrix. A “nearly-regular cross” is defined as follows:

  • A cross is formed by choosing a cell as the center, taking its row as the horizontal arm and its column as the vertical arm.
  • Collect all numbers appearing in that row and column.
  • If all numbers are identical, it is a regular cross (valid).
  • If there are exactly two distinct numbers and one of them appears only once, and that unique element is the center cell, then it is a nearly-regular cross (also valid).
  • Otherwise, it is not valid.

Return the total number of valid (regular + nearly-regular) crosses in the matrix.

Example 1:

Input:
matrix = [
  [1, 1, 1],
  [1, 2, 1],
  [1, 1, 1]
]

Output: 1
Explanation:
Only the center cell (value 2 at position [1,1]) forms a nearly-regular cross.
All rows/columns contain only 1s except the center element = 2, so it is valid.

Example 2:

Input:
matrix = [
  [5, 5, 5],
  [5, 5, 5],
  [5, 5, 5]
]

Output: 9
Explanation:
Every cell can be chosen as the center, and all of them form a regular cross.
Total = 9.

如果你也在準備 Capital One、Citadel、或者 Amazon 這一類 OA/VO,其實完全不用單打獨鬥。Programhelp 可以給你提供無痕遠端連線助攻:比如即時語音提醒、debug 思路點撥、代碼結構優化,讓你在緊張的考試環境里少走彎路,把精力放在思考而不是卡殼上。 很多同學反饋說,有了及時的提醒,就能穩定輸出高品質答案,大大提升通過率。

author avatar
jor jor
END
 0
Comment(尚無留言)