Skip to content
Related Articles

Related Articles

Media.net Interview Experience 2021

View Discussion
Improve Article
Save Article
  • Difficulty Level : Expert
  • Last Updated : 06 Aug, 2021
View Discussion
Improve Article
Save Article

Online Assessment:

  1. Given a tree rooted at 1 with n nodes, q queries are given. In each query, d, e are given as input. You need to find the maximum value of e^x where x is one of the ancestors of d or d itself in the tree.
    n<=10^5
    q<=3*10^5
    e<=3*10^5
    1<=d<=n
  2. A bus stops at n bus stops, each bus stop having a[i] people. The bus needs to take in all the people on the bus. People from 1 bus stop get down before the next bus stop arrives. They use a resizing tech which allows the bus to be resized to whatever capacity they want. This action can be done only b times at max. The uselessness of the bus is the summation of a total number of unoccupied seats across n stops. Find the minimum uselessness the bus can achieve if the resizing tech is used optimally. 1<=a[i]<=10^6, 1<=b<=n<=400
    Ex 1:
    a = [10 20] b = 0
    Ans:10

    Explanation – the resizing tech cannot be applied. hence the capacity of the bus is 20 initially. in the first stop, 20-10 seats were unused. in the second stop 20 – 20 seats are unused. Total unused seats = 10

    Ex 2:
    a = [10 20 30] b = 1
    Ans: 10

    Explanation – the resizing tech can be applied only once. The capacity of the bus is 10 initially. in the first stop 10-10 seats unused = 0. in the second stop, the tech is used to resize to 30. 30 – 20 seats unused.

    In the third stop,  30-30 seats unused

    Total unused seats = 10.

  3. You will be given n points in a 2D plane which represents the corona orange zone. On the i-th day, Corona will spread to all the locations which are within i euclidean distance from each Corona orange zone. A zone will become red, if it coincides with atleast ‘x’ orange zones. Given the n  pairs and x, find the day in which the first red zone occurs.
    1<=n<=100, 1<=b<=n, 
    for each point, 
    1<=x<=10^9, 1<=y<=10^9
    Example-
    (9,4),(10,3) , x=2.
    Ans : 1

    In point (9,3) both the zones would have been affected after day 1. Hence it will become a red zone after day 1.

Interview Round 1: I was asked to introduce myself. After a short introduction, I was directly given a problem. The problem is as follows:

  1. You are given 4 strings w,x,y,z. You can permute each of the strings however you want. You have to fix 1 permutation for each of the 4 strings such that when you add all the 4 strings into a trie, the number of nodes created in the trie is minimized.
    Example-
    w = abaa
    x = aaaa
    y = acca
    z = abca
    For permutaion:
    w = abaa
    x = aaaa
    y = acca
    z = abca

    Number of nodes in Trie – 1 (number of new nodes for first character of all strings) + 3(for second character ) + 4(for third character ) + 4(for fourth character ) = 12

    minimum number of trie nodes when:

    w = aaab
    x = aaaa
    y = aacc
    z = aacd
    Number of nodes : 
    1 + 1 + 2 + 4 = 8

    I gave a O(2^ (number of words (4 in this case)) * number of characters(26 in this case)) using bitmasks. The interviewer was convinced.

Interview Round 2: There was a small introduction. Then the interviewer directly jumped into a problem.

  1. You are given a 2D array of integers with dimension n X m and a value ‘k’. Find if there exists a square submatrix whose sum is equal to k.
    Example-
    n = 3, m = 3, k = 10
    1 2 3
    2 3 4
    3 2 6
    Output: true

    Explanation: The square starting from (1,0) to (2,1) (Zero based indexing) has a sum 2 + 3 + 2 + 3 = 10 which is equal to k.

    I first gave O(m*n*min(m,n)) solution using DP and optimised it O(m*n*log(min(n,m))) using binary search. But the expected solution was O(m*n) using 2 pointers.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!