Robo Data Sharing Direction
Updated
Problem statement
Robots occupy every cell of a rows by cols matrix. Data starts at one corner, (startRow, startCol), using 1-based coordinates.
After a robot consumes the data, it passes the data to the first adjacent robot that has not consumed it, using this priority:
Right:(row, col + 1).Left:(row, col - 1).Front:(row - 1, col).Back:(row + 1, col).
For the queried robot (row, col), return the direction in which it passes the data. Return Over if it is the final robot to consume the data.
Function
nextDataDirection(rows: int, cols: int, startRow: int, startCol: int, row: int, col: int) → StringExamples
Example 1
rows = 3cols = 3startRow = 1startCol = 1row = 3col = 3return = "Over"Starting at the top-left corner produces a row-by-row snake traversal. Cell (3, 3) is last.
Example 2
rows = 2cols = 3startRow = 1startCol = 3row = 2col = 2return = "Right"The first row is traversed right-to-left. After moving down, the second row is traversed left-to-right, so (2, 2) passes data right.
Constraints
rowsandcolsare positive.(startRow, startCol)is one of the four corners.1 <= row <= rowsand1 <= col <= cols.
More Arcesium Online Assessment questions
- City Infection NumberOA · Seen Jul 2025
- Minimum Tunnel Crossing TimeOA · Seen Jul 2025
- Product of Subset MaximaOA · Seen Jul 2025
- Reconstruct the Root StreamOA · Seen Jul 2025
- Add DigitsOA · Seen Aug 2023
- Binary Tree Maximum Path SumOA · Seen Aug 2023
- Detect a Cycle in Directed Hate RelationshipsOA · Seen Aug 2023
- Reverse First K Characters in Every 2K BlockOA · Seen Aug 2023
- Capital Gains Tax from TradesOA · Seen Feb 2021
- K-th Character in an Infinite StringOA · Seen Aug 2020
Similar questions at other companies
- Wind-Blown Leaves Remaining in a GridAbridge · OAAbridge interview questions
- Invert or Blur an ImageOpenAI · OAOpenAI interview questions
- Trapped Characters in a GridAdobe · OAAdobe interview questions
- Simulate a Deterministic Finite AutomatonPoint72 · OAPoint72 interview questions
- Transform Binary MatrixVisa · OAVisa interview questions
- Collect Letters Along a Unique Grid PathApple · OAApple interview questions
- Count Pieces After Othello MovesHudson River Trading · OAHudson River Trading interview questions
- Rover MoveIBM · OAIBM interview questions
- Tic-Tac-Toe Board StatusPinecone · OA
- Orthogonal Neighbor Grid TotalIMC Trading · OAIMC Trading interview questions