Company: Agoda_8nov
Difficulty: medium
Gridland Problem Description Gridland is a 2D world divided into cells, with each cell represented by coordinates (x, y) where (0, 0) is the top-left corner. From any cell (x, y), a resident can move either horizontally or vertically to an adjacent cell i.e. (x + 1, y) or (x, y + 1). Each possible minimum path is a sequence of horizontal and vertical moves denoted by the characters H and V. For instance, the path 'HVHV' describes the sequence of moves from (0, 0) to (2, 2) as horizontal → vertical → horizontal → vertical. A specific path through Gridland must be identified. Start by generating all possible paths from the origin to the target location, represented as strings of H and V. Order these strings in alphabetically ascending order. Return the path at the zero-based index position of a given key value, the safe path. For example, consider a 2x2 grid where the move is from position (0,0) to (1,1). All possible paths are (0,0) → (0,1) → (1,1) = 'HV' and (0,0) → (1,0) → (1,1) = 'VH