← 返回 apple 的题目列表Path Existence Following Slashes in Matrix Directions
类型:online_judge
apple
Path from Top-Left to Bottom-Right in a Matrix
Given a 2D matrix where each element is a string of a slash ('/') or a backslash (''), write a function to determine if there exists a path that allows moving from the top-left to the bottom-right of the matrix by traveling along slashes in their indicated directions. Note that the path can only follow the direction of the slashes.
Input:
matrix: List[List[str]], a matrix consisting of strings '/' or ''.
Output:
bool, indicating whether a path exists from the top-left to the bottom-right.
Example:
Input: [['/', '\'], ['\', '/']]
Output: true
Constraints:
The side length of the matrix does not exceed 100.
Example
Input
[['/', '\\'], ['\\', '/']]