![]() |
VOOZH | about |
Round One Coding test of 1.5 Hours:
It was an online coding test conducted on HackerRank. A test consisting of 3 coding questions.
Example : D - 2 , arr = {1,2,4,7,8,9,10,12,14,16,18,20}
Output : 4
Explaination :- (1,2,4) , (7,8,9,10) ,
(12,14,16) , (18,20) , workers will
be divided like this
(50 Marks) - O(N) solution accepted
(HINT: sort the array and take the group of people in a 2D distance at once)Input Format :- N : total documents OPS - total operations next ops line will contain 3 space separate integers say(op , doc1 , doc2) where the first integer (op) denotes operation type and remaining two are documents numbers op = 0 , means next 2 documents are similar
OUTPUT :- Single integer in new line for every query , 0 if documents are not duplicate , 1 if documents are duplicateSingle integer in new line for every query , 0 if documents are not duplicate , 1 if documents are duplicate
EXAMPLE :- 10 5 0 1 2 0 5 7 1 1 3 0 2 3 1 1 3
OUTPUT :- 0 1 7
EXPLAINATION :- There are total of 10 documents Given 5 operations are :- 1) Mark the document 1 & 2 duplicate 2) Mark the document 5 & 7 duplicate 3) Query if document 1 & 3 are duplicate , hence the first line in output 0 4) Mark the document 2 & 3 duplicate 5) Query if document 1 & 3 are duplicate , hence the second line in output 1 Print total unique documents now (1,2,3) , (5,7) , (4) , (6) , (8) , (9) , (10) = total 7 unique documents
Hint :- two ways through which this problem can be solved 1) using dfs traversal in each query , similar to count total number of connected components 2) using disjoint set union method
Constraints 1<= N <= 10^5 1<= P <= 10^2 1<= N*P <= 10^6 1<= Li , Ri <= 10^9 1<=Ki <= 10^6 Example :- consider N=3 and P=2 and the intervals are 1 3 10 2 5 15 5 7 6 Here the answer is 16 , as taking 1st and 3rd intervals will be optimal
Input Format :- first line contains N and P N lines follow 3 space separated integers Li , Ri , Ki
Sample Input 3 2 1 3 10 2 5 15 5 7 6 Sample Output 16 HINT :- Try to think DP with Binary Search in every recursive stack.
Students who scored more than 125 marks (partial marking is also there) were selected for interview in Sprinklr.