Ascend Vertical Wall (For off-campus 2025 batch hiring :)
Heads up~~ The OP mentioned that the description of this question might not be very accurate or polished as they could barely recall the question now.
A robot whose battery capacity is w, wants to ascend a vertical 2D wall
(N x M). It can start from any cell in the bottom row and wants to reach any
cell in the top row. Each cell can be 'x', meaning the robot can hop on that cell or a '.',
meaning the robot can't hop on that node. However, there are some conditions it has to follow:
(x₁, y₁) can only jump to (x₂, y₂),
if the Euclidean distance between these two cells is less than or equal to w
(robot battery capacity).The first line of input is the number of rows, number of columns, and the battery capacity. The second line is a 2D wall cell graph.
Complete the function canAscend in the editor.
canAscend has the following parameter:
String[][] wall: a 2D array representing the wall cells
Returns
int: the minimum number of hops required to ascend the wall, or -1 if it's not possible