Company: Scienaptic AI_11oct

Difficulty: medium

Problem Statement

Virus Spread in a Ship Problem Description A cruise ship's seating chart is laid out as an m x n grid, where m is the number of rows and n is the number of columns. One seat's occupant carries a virus that spreads to occupants in adjacent seats. Every hour, the virus reaches any adjacent seat — left, right, above, or below — but it never jumps diagonally. Given the seat where the virus starts, work out the greatest number of hours needed for the virus to reach every seat on the ship. Input: An integer m , the number of rows in the ship's seating grid ( 1 <= m <= 10 ). An integer n , the number of columns in the ship's seating grid ( 1 <= n <= 100 ). A string startPosition giving the initial infected seat in the format "x,y", where x and y are its row and column. Output: Return an integer giving the greatest number of hours needed for the virus to reach every seat. If every seat is already infected at the start, return 0. Examples Example 1: Input: m = 5, n = 9, startPositio

More Scienaptic AI_11oct OA questionsInterview experiences