Zepto : Online Technical Coding Interview Experience

I called from 3rd party for the interview.

Round 1 :
Some technical questions and database related stuffs.

1. Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required.

Example
Example1

Input: intervals = [(0,30),(5,10),(15,20)]
Output: 2
Explanation:
We need two meeting rooms
room1: (0,30)
room2: (5,10),(15,20)


Example2
Input: intervals = [(2,7)]
Output: 1
Explanation: 
Only need one meeting room



Int getMinimumConferenceRoom(vector<vector<int>> meetings){

map<int , int> m;
Int rooms = 0; 

for(vector<int> meeting : meetings){
    
m[meeting[0]]++;
m[meeting[1]]--;


}

// [0 , 30] [30 , 40]

M[0] = 1;
M[30] = 0;
M[40] = -1;


int count = 0;
for(pair<int , int> p : m){

   count += p.second;
Ans = max(ans , count );

}

Return ans;




}

Space :  O(n)
Time : O(nlogn)


2. Given an array nums which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays.

Write an algorithm to minimize the largest sum among these m subarrays.

 

Example 1:

Input: nums = [7,2,5,10,8], m = 2
Output: 18
Explanation:
There are four ways to split nums into two subarrays.
The best way is to split it into [7,2,5] and [10,8],
where the largest sum among the two subarrays is only 18.

7 | 2 5 10 8 -> 25
7 2 | 5 10 8 -> 23
7 2 5 | 10 8 -> 18
7 2 5 10 | 8 -> 24

Class DBConnection{

Static public $dbConn;

Private DBConnection(){
}


Static getConnection(){
   if( empty($dbconn)){
      $dbconn = new $_SELF_CLASS;
}

Return $dbConn;

}

}

Recieved the mail fo selection of 2n round but didn’t got any call.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
error

Enjoy this blog? Please spread the word :)

0
Would love your thoughts, please comment.x
()
x