As reported: Apple IS&T software engineer (Hyderabad, 2025), online assessment on CoderPad — two Java-based questions in 70 minutes; this was the first. The same question appeared in the OA for a Junior Software Engineer (ICT2) role in 2025.
You are given a list of strings that form a 2D grid. The grid is always 15 characters wide and 10 rows high; (0, 0) is the first character of the first string.
The grid contains exactly one path made of * and lowercase letters:
- it starts at
(0, 0); - it moves up, down, left or right — never diagonally;
- it has no forks and no loops, and it ends somewhere in the grid.
Follow the path from start to end and record the letters in the order you meet them (skip the stars). Return the resulting string.
The path may start with a letter and may end with a letter. It is at least two characters long and contains at least one letter.
Example 1
**a.*b*........
..*.*.*........
..*c*.d........
............... -> "acbd"
(6 more rows of dots)
Example 2
xy.............
(9 more rows of dots) -> "xy"
Example 3
h*..*****i.....
.*..*..........
.*e**.......... -> "hei"
(7 more rows of dots)
Clarifications
- Cells that are not on the path hold
.. - The path never touches itself: every path cell except the two ends has exactly two path neighbours, and each end has one. So from any cell there is exactly one way forward.
Constraints: 10 strings of 15 characters each; each character is *, . or a lowercase letter.
Code runner format: the 10 rows of the grid, one per line. Implement followPath(grid); the harness prints the returned string.