Microsoft OA 17-02-2025
Anonymous User
626
  1. given N, A[], B[] and H[]
    A[] = from/to district
    B[] = from/to district
    H[] = hospital district

    we have to return time it takes to reach to farthest district from any hospital; it takes 1 minute to cross one district. if district is unreachable then return -1;

    example 1 : N = 6 A[] = [1,1,0,1,3] B[] = [2,0,5,3,4] H[] = [2,4]

    output = 3 (since from 2 farthest is 5 which have distance as 3)

    image

    example 2 : N = 6 A[] = [1,1,2,3,3,5] B[] = [6,2,3,4,5,6] H[] = [1,4]

    output = 2 (since from 1 or 4 farthest is 5 which have max distance as 2)

    image

    example 3 : N = 6 A[] = [1,2,3,3] B[] = [2,3,4,5] H[] = [1,4]

    output = -1 (since from any hospital we cannot reach 6)

image

example 4 : N = 3 A[] = [1] B[] = [2] H[] = [1,2,3]

output = 0 (since every district is hospital)

image

  1. given 2 strings
    s1 = ".xxx...x"
    s2 = "..x.xxxx"

string represents a road with "." as smooth and "x" as potholes. we have to fix the potholes so we need to block the some part of road. but road must be open in such a way that pasenger can pass from left to right; we have to return the number of potholes we can fix while keeping the traffic open.

example 1 : s1 = "..xx.x." s2= "x.x.x..." output = 4 (since if we use shown path then 4 potholes can be fixed"

image

example 2 : s1 = ".xxx...x" s2 = "..x.xxxx" output = 6 (since if we use shown path then 6 potholes can be fixed"
image

example 3 : s1 = "xxxxx" s2 = "..x.." output = 5 (since if we use shown path then 5 potholes can be fixed"
image

verdict : not selected

Comments (5)