ByteDance Online Assessment 经验分享 | CodeSignal 高频题方向

1,117閱讀
沒有評論

最近帮学员刷到了一套 ByteDance Online Assessment ,时间是 9.10,当天刚测完就来分享一下最新情况~

ByteDance 的 OA 平台依旧是 CodeSignal,跟大家熟悉的 Uber / Roblox / HRT / TT 那套通用题库差不多,整体模式就是 70 分钟 4 道题。所以如果你之前做过这些公司的 OA,遇到的题型和套路基本八九不离十。

ByteDance Online Assessment

这次测下来的感觉:

  • 时间确实比较紧,写 4 道题不能有太多卡顿。
  • 题库重叠度高,但每次数值和细节会有点变化,不能完全照搬。
  • 出题思路偏经典数据结构+模拟,比如 array、string、greedy、小 dp。

整体难度不算爆炸,但要想 70 分钟全 AC,还是要提前熟悉 CodeSignal 的题型套路,尤其是边界和 corner case,容易掉坑。

ByteDance Online Assessment 独家真题复现

Problem 1: Maximum Square Area in City Skyline

You need to analyze the potential space in a cityscape outlined by a series of skyscrapers. Each element in the array cityline represents the height of a skyscraper, with each skyscraper having a width of 1. They are placed directly adjacent to each other along a road with no gaps. Your task is to determine the largest square area that can fit within this row of skyscrapers.

Example

  • For cityline = [1, 2, 3, 2, 1], the output of solution(cityline) should be 4.
    In this configuration, there are multiple 2×2 squares that can be accommodated between the skyscrapers, but no larger square can fit due to height limitations.

Problem 2: Number of Nearly Regular Crosses

For a rectangular matrix of integers, a cross is a figure formed by the intersection of one row and one column. A cross is considered regular if all its elements are equal.

A nearly regular cross is one where all elements are equal except possibly the element at the intersection of the row and column that form the cross.

Given a rectangular matrix of integers matrix, your task is to return the number of nearly regular crosses in the matrix. Note that by definition, regular crosses are also considered nearly regular crosses.

Note: You are not expected to provide the most optimal solution, but a solution with a time complexity no worse than O(matrix.length · matrix[0].length · (matrix.length + matrix[0].length)) will fit within the execution time limit.

Example

For

matrix = [
  [1, 1, 1, 1],
  [2, 3, 1, 1],
  [1, 1, 1, 0],
  [1, 4, 1, 1]
]

the output should be 10.
Explanation: There are 10 crosses in this matrix that meet the definition of a nearly regular cross. For example, the cross formed by row 0 and column 0, where elements other than the intersection meet the conditions; the cross formed by row 2 and column 2, where all elements are equal (a regular cross) and thus counted as a nearly regular cross. The total count is 10.

Problem 3: Optimal String Reversal

Given a string word, you can form new strings by reversing the order of some characters from the beginning or the end of word.

Reversing the first k characters of a string |w₀…wₖ₋₂wₖ₋₁|wₖ…wₙ₋₁ (where the part within |…| is reversed) results in |wₖ₋₁wₖ₋₂…w₀|wₖ…wₙ₋₁.

Reversing the last k characters of a string w₀…wₙ₋ₖ₋₁|wₙ₋ₖwₙ₋ₖ₊₁…wₙ₋₁| (where the part within |…| is reversed) results in w₀…wₙ₋ₖ₋₁|wₙ₋₁…wₙ₋ₖ₊₁wₙ₋ₖ|.

Your task is to iterate over all possible new strings that can be formed this way and return the lexicographically smallest one.

Note: You are not expected to provide the most optimal solution, but a solution with a time complexity no worse than O(word.length³) will fit within the execution time limit.

Example
For word = "dbaca", the output of solution(word) should be "abdca".
All possible reversal operations are as follows:

Reversing the first 1 character results in "dbaca".

Reversing the first 2 characters results in "bdaca".

Reversing the first 3 characters results in "abdca".

Reversing the first 4 characters results in "cabda".

Reversing the first 5 characters results in "acabd".

Reversing the last 1 character results in "dbaca".

Reversing the last 2 characters: the last 2 characters of the original string are “ca”, which become “ac” after reversal, resulting in "dbaca".

Reversing the last 3 characters: the last 3 characters of the original string are “aca”, which remain “aca” after reversal, resulting in "dbaca".

Reversing the last 4 characters: the last 4 characters of the original string are “baca”, which become “acab” after reversal, resulting in "dacab".

Reversing the last 5 characters (reversing the entire string) results in "acabd".

Among all possible results, the lexicographically smallest is "abdca".

备考建议

刷通用题库:重点看 CodeSignal 高频题,尤其是数组 + 字符串的变形题。

训练写题速度:平时模拟最好就卡在 70min,强迫自己快速 debug。

注意 test cases:多写几个极端 case,比如空数组 / 最大值 / 单字符等。

保持心态:有一道题卡住,不要死磕,先跳到下一题,保证整体分数。

语言选择:如果 C++ / Java 熟练,优先用这些,性能稳定;Python 需要提前准备优化手段。

有陪跑,效率翻倍

比起狂刷题库,真正拉开差距的其实是临场表现。我们能在实战中帮你点出细节,比如什么时候该跳题、哪里要补 edge case,少掉一次坑就可能多 AC 一题。这些小细节,往往决定了能不能进下一轮。如果你也在准备 ByteDance、Uber、HRT、Roblox 或其他大厂 OA,别硬扛,我们这边有 OA远程无痕面试助攻 + 代面试,让你像真实面试一样提前适应辅助节奏。有需要的同学可以直接来找我们聊,少走弯路,把机会抓在手里。

author avatar
jor jor
正文完
 0
评论(沒有評論)