Ascend Vertical Wall (For off-campus 2025 batch hiring :)
Learn this problemProblem statement
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.
Function
canAscend(wall: String[][]) → int
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
Examples
Example 1
wall = [["x","x",".","x"],[".","x",".","."],[".","x",".","x"], [".", "x", ".", "."]]return = 2More Uber problems
- Minimum Refueling StopsONSITE INTERVIEW · Seen Jul 2026
- Last Truck to Leave the LaneOA · Seen Jul 2026
- Chain of CommandOA · Seen Jul 2026
- Jump Game with Prime-3 StepsOA · Seen Jun 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026