Question: Blue Optima | Online Round | Set-1 | 19-08-2020
0
Entering edit mode
Blue Optima visited for 5 different Profiles.
  1. Back End Developer (Java)
  2. SDE in Testing
  3. UI Developer (Javascript)
  4. DevOps
  5. Data Engineer (Machine Learning and Data Mining Expert)
The Online Round had three sections.
1. Aptitude
2. Technical ( OS / CN / DBMS / OOPS / DSA)
3. Coding

1st Coding Question

For a array of positive integers your are given a positive integer K.
Choose any contagious subarray such that its sum is divisible by K.
Your task is to output the largest possible sum that follows the given constraints.

2nd Coding Question

A 2-D grid contains integers from the set -> {0,1,2}.
0 -> The Cell is Empty.
1 -> The Cell is blocked.
2 -> Initial Position (Guaranteed only one such cell exists).
Starting from you initial position you can either move horizontally or vertically.
You cannot enter any blocked cell and also you cannot exit the grid.
Output the minimum distance to be traversed to reach any edge of the grid or else state its impossible.
ADD COMMENTlink 4.3 years ago Shubhendu Goel • 450
2
Entering edit mode
First Problem

Let prefix_sum be the prefix sum array

For i in range [0,n-1], calculate prefix_sum[0,i]%K.

Group these indexes of prefix sums by the above computed value. Note that there can be at most K groups.

We are only interested in the combinations of 2 prefixes ending at i and j respectively in the same group as the difference between is the subarray sum[i+1,j] which is divisible K. Moreover, for each group having at least 2 elements, we choose the two elements having extreme indexes in the array. For example group 5 has elements [1,5,7,10,13], then we choose index 1 and 13 as this will maximize our subarray sum. Find the maximum subarray sum iterating over all the valid groups.

The maximum of them is the answer.
Time complexity: O(N)

Second problem

A simple grid BFS problem. Do a simple BFS in the grid starting at cell which contains 2.

As soon as you reach an edge (you can just apply a simple check for eg for the left edge of the grid the check is j==0, where j is the column number), you get the answer for this edge.
ADD COMMENTlink 4.3 years ago vaibhavr • 370

Login before adding your answer.

Similar Posts
Loading Similar Posts