Palo Alto 面试题|Grid 点击激活与异步状态反转 – 面试真题 – 前端面试题

21次阅读
没有评论

Problem Description

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.
You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates
that you must take course bi first if you want to take course ai.

Return the ordering of courses you should take to finish all courses.
If there are many valid answers, return any of them.
If it is impossible to finish all courses, return an empty array.
Palo Alto 面试题|Grid 点击激活与异步状态反转 - 面试真题 - 前端面试题

Example 1

Input: numCourses = 2, prerequisites = [[1,0]]
Output: [0,1]

Example 2

Input: numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]]
Output: [0,2,1,3]

Example 3

Input: numCourses = 1, prerequisites = []
Output: [0]

A practical UI problem involving event ordering, async timing, and controlled state rollback.

这是一个 事件顺序 + 异步控制 + 状态回放 的综合题,非常贴近真实前端交互逻辑。

正文完
 0