Goldman Sachs | OA | Analyst(May 2020)
Anonymous User
1212

Duration 1h 15 min

Total 3 coding problems

  1. Total jumps to reach end of array [Easy]
    given the array arr of positive integers and two positive integers X and Y represents maximum jump that can be made left side and right side respectively.
    Find total jump if it possible to reach end of array and if it is not possible then return to the start and return total jump-count.

    Example 1:
    Input: [1,2,5,3,4,7,8,3], x=5, y=3
    Output: 9
    Exaplnation: initially at 0 then make right jump 1 diff=1(<=y) then again 1->2 diff=1(<=y) , 
    2->5, then it makes a jump left of 2 ,[5->2]=> diff=3(<=x) and so on.
    At the end [3->0] => diff=3(<=x).
    
    Example 2:
    Input: [1,2,3,4,1], x=2, y=2
    Output: 8
    
    Explanation: [0->1],[1->2],[2->3] [3->4] now to make next jump (4-1) =3 (>Y) needed 
    but only 2 provided so it will also make return jumps that's why count is double.
    1. Don't remember[Medium]

    2. Minimize enemies to kill [Hard]
      Given a 2D grid of characters with values '0', '1', 'X'. and two special characters A and B.
      Find minimum number of enemies to kill such that we can get both special characters and get out of the Grid.

      0 means there is no wall.
      1 means wall or blocked path.
      X represents Enemies **(once killed can be converted to 0)**

      Example 1:
      image

       Output: 3

Please comment down your approach for the 3rd problem.

Comments (1)