最近帮学员过了微软的 online assessment,总结下来感觉微软的 OA 真的是“套路化”明显。题目池固定,重复率很高,基本掌握好常见 patterns,刷过几套题,拿下完全没问题。这篇文章就来分享一下最新的微软 OA 真题和常见题型,希望能帮到正在准备的同学们。

Microsoft OA流程回顾
微软的 OA 一般是两道编程题 + 少量逻辑/数理小题,时间大概 90 分钟。每道编程题平均要花 30 分钟左右,所以时间管理特别关键。我们学员的反馈是,卡太久容易慌,最好先做会的,难的放后面。
題型分佈
根据这次以及往届同学反馈,题型主要分布:
- String processing 占大头
- 常见考点:consecutive characters、palindrome、lexicographic order。
- 本质就是对字符串扫描、分段、比较,难度中等,但细节多。
- Array & Graph 基础题
- 偏向常规算法,比如 array manipulation、BFS/DFS。
- 不会出太怪的题,主要看基本功扎实不扎实。
- 经典 patterns 高频考
- Two Sum 系列
- Sliding Window
- Greedy choice(interval/substring 类型)
- 动态规划偶尔会考,但一般不深。
Microsoft OA Simulation Questions
I. Programming Problems (2 Questions)
Programming Problem 1: Longest Valid Parentheses
Problem Description
Given a string containing only ‘(‘ and ‘)’, find the length of the longest valid (well-formed)parentheses substring. A valid parentheses substring must have properly paired and nested parentheses. For example, “()()” and “(())” are valid parentheses substrings, while “())” and “(()” are invalid.
Examples
- Example 1: Input: s = “(()”, Output: 2. Explanation: The longest valid parentheses substring is “()”, with a length of 2.
- Example 2: Input: s = “)()())”, Output: 4. Explanation: The longest valid parentheses substring is “()()”, with a length of 4.
- Example 3: Input: s = “”, Output: 0.
Requirements
- Time complexity must not exceed O(n) (where n is the length of the string).
- Space complexity must not exceed O(n).
Programming Problem 2: Task Scheduler
Problem Description
Given a character array representing tasks that a CPU needs to execute. Each letter represents a different type of task. Tasks can be executed in any order,and each task takes 1 unit of time to complete. At any unit of time, the CPU can either execute a task or be in an idle state.
There must be a cooldown period of integer length n between two tasks of the same type. That is, there must be at least n consecutive units of time where the CPU is either executing a different task or in an idle state.
Calculate the minimum time required to complete all tasks.
Examples
- Example 1: Input: tasks = [“A”,”A”,”A”,”B”,”B”,”B”], n = 2, Output: 8. Explanation: One possible execution order is A -> B -> (Idle) -> A -> B -> (Idle) -> A -> B, with a total time of 8 units.
- Example 2: Input: tasks = [“A”,”A”,”A”,”B”,”B”,”B”], n = 0, Output: 6. Explanation: There is no cooldown period, so all taskscan be executed in sequence directly, with a total time of 6 units.
- Example 3: Input: tasks = [“A”,”A”,”A”,”A”,”A”,”A”,”B”,”C”,”D”,”E”,”F”,”G”], n = 2, Output: 16.Explanation: One possible execution order is A -> B -> C -> A -> D -> E -> A -> F -> G -> A -> (Idle) -> (Idle) -> A -> (Idle) -> (Idle) -> A, with a total time of 16 units.
Requirements
- Time complexity must not exceed O(m) (where m is the length of the task list).
- Space complexity must not exceed O(26) (since tasks only consist of 26 uppercase English letters).
II. Logical/Mathematical Mini-Questions (5 Questions)
Mini-Question 1: Logical Reasoning
A Microsoft team has three engineers: Jia, Yi, and Bing, each responsible for one of three areas: Frontend, Backend, and Algorithms. The followinginformation is known:
- Jia is not responsible for Frontend;
- Yi is not responsible for Backend;
- The engineer in charge of Algorithms and the engineer in charge of Frontend are colleagues and have different genders (assuming the three have differentgenders, and Jia is male).
Which area is Bing responsible for?
A. Frontend B. Backend C. Algorithms D. Cannot be determined
Mini-Question 2: Mathematical Calculation
There is a positive integer array with all distinct elements. When each element in the array is multiplied by 2, the number of elements in the intersectionof the new array and the original array is half the length of the original array, and the length of the original array is even. It is known that the smallestelement in the original array is 1 and the largest is 10. What could be the length of the original array?
A. 2 B. 4 C. 6 D. 8
Mini-Question 3: Probability Problem
A bag contains 5 red balls and 3 white balls. One ball is randomly drawn from the bag each time, and the ball is not put back after drawing. Two balls are drawnconsecutively. What is the probability that the first ball drawn is red and the second is white?
A. 15/56 B. 15/28 C. 5/14 D. 3/14
Mini-Question 4: Logical Thinking
In a software development project, four modules (A, B, C, D) need to be completed, with dependency relationships between the modules as follows:
- Module B can only start after Module A is completed;
- Module D can only start after both Modules B and C are completed;
- Module C can start at any time (no pre-dependencies).
If the development time for each module is 2 days, and only one module can be developed at a time, what is the minimum time required to complete all modules?
A. 6 B. 8 C. 10 D. 12
Mini-Question 5: Mathematical Analysis
It is known that the three sides of a right-angled triangle are all integers, and the length of one of the right-angled sides is 12. What is the maximumpossible perimeter of this right-angled triangle?
A. 84 B. 90 C. 96 D. 102
不在孤军奋战:带你轻松通关微软OA
微软的 OA 看似套路,其实细节和陷阱不少。很多同学卡在边界条件或者时间分配,一不小心就影响整体表现。其实只要方向正确,OA 完全是可以“拿捏”的一关。
如果你不想一个人硬扛,Programhelp 可以给到实时的OA远程无痕助攻:
即時語音提醒,遇到卡点直接点拨思路;
联机代写支持,代码细节全程无痕衔接;
提前 mock 练习,模拟真实考试节奏。
有了助攻,不仅能节省时间,还能把握住微软这类高重复率的 OA。