Total Question: 4

  1. Given a time duration of a trip and an array of duration of music. Select a pair of music who sum is lower than 30 seconds less than trip duration and closest to trip duration. If we have two pairs of music with equal duration then select the pair with larger music.
    a: [10,20,30,30,40] duration=90
    ans=20+40=60 not 30+30
    we have to return the indices of the music
  2. Explain the approach and time complexity of ques 1.
  3. Given a 2D grid with 0's and 1's. 0 means blocked. Initially we are present at (0,0). We have to move to a cell with value=9.Return the minimum number of steps. We can move up,down ,right and left. not diagonally.
    ex: 1 0 0 0
    1 1 9 1
    1 0 0 0
    ans=(0,0)->(1,0)->(1,1)->(1,2)
    distance = 3
  4. Explain the approach and time complexity of ques 3.
Comments (7)