Round one : (Coding test)
It was an online coding test conducted on HackerEarth. A test consisting of 3 coding questions.
- Given two binary strings A and B. In one move you can choose any two numbers from string A and replace any of them with XOR of them and another one with OR of them. Ex: A=0010110. You chose 0 and 1 so, 0 XOR 1=1 and 0 OR 1=1 so, 01 becomes 11. You can apply this move on string A any number of times and it is possible to make string B from A then return YES otherwise NO. (50 Marks)
- Answer : Count number of ones in both string. lets counts be cnt1 and cnt2. answer is “YES” if (cnt1<=cnt2 && cnt1>0 || cnt1==0 && cnt2==0), otherwise answer is “NO”. Do not forget to check length of two strings. Obviously answer will be “NO” if strings are of different length.
- Here, I can increase the number of 1s in A (by choosing one 1 and one 0 -> both become 1)
- I can swap any 1 with any other 0 A (by choosing one 1 and one 0 -> both become 1 -> one become 1 and other 0)
- But, for doing above operations I need atleast one 1.
- Also, I cannot reduce the number of 1s.
- given an integer matrix(m) of the NxM dimension.In one move you can go from position (i,j) to either (i+m[i][j] , j) or (i,j+m[i][j]). Initially, you are on at (1,1) and you wanted to reach (N, M). So, you have to print a minimum number of moves to reach (N, M), and if it is not possible then print -1. NOTE: You can not jump outside the matrix. (i.e. in any move i+m[i][j] < N or j+m[i][j]<M). (75 Marks) Hint: can be solved using BFS or using 2D matrix.
- There are N different packages. the ith package is of X[i] days and the price of that package is Y[i]. There are M customers. the jth customer wants the package of at least A[j] days and he doesn’t want to spend more than B[j] for any package. One package can accommodate at most one customer (Social Distancing) and a customer can buy at most one package. You have to find the maximum number of packages, you can sell. (100 marks)
I got 215 out of 225. So i was shortlisted for next round along with 65 others.
Round Two: Technical Round (F2F) | Online
There were two interviewers. Both were really friendly and kept a very comfortable environment through out the interview. Most of the questions were on competitive coding and puzzles.
Interview Level : easy/Medium
2) puzzle : https://math.stackexchange.com/questions/2440047/colour-change-in-drawing-balls-expectation-same
3) puzzle : https://www.geeksforgeeks.org/puzzle-1-how-to-measure-45-minutes-using-two-identical-wires/
Note: There can be variation like measure 15 minutes, 30 minutes or 60 minutes
4) https://www.geeksforgeeks.org/sliding-window-maximum-maximum-of-all-subarrays-of-size-k/ Do not directly jump on optimized solution as this question can be solved using 2/3 methods.
Note: question can be asked for finding minimum in all sub-arrays of size k
Expected time complexity: O(n)
5) Explain particular project pointed out by interviewer.
6) Topological sort explanation and implementation
one/two more questions were asked but i don’t remember.
Round Three: Technical Round (F2F) | Online
Interviewer was helpful. He gave me hints whenever i got stuck in any problem.
1) You are given two integers l and r. Find two integers x and y such that l?x<y?r and l?LCM(x,y)?r
Input: The first line contains one integer t (1?t?10000) — the number of test cases. Each test case is represented by one line containing two integers l and r (1?l<r?109).
Output: For each test case, print two integers: if it is impossible to find integers x and y meeting the constraints in the statement, print two integers equal to ?1; otherwise, print the values of x and y (if there are multiple valid answers, you may print any of them).
2)you are given an integer x, it doubles its value every second and after that it can decrease its value by one if it remains positive. what is the expected value of x after k seconds.
Example : after one second ,value of x can be 2x or 2x-1. so expected value of x after one second is 2x-1/2.
constraint: 1<= x,k <=10^18
Then he asked me what if 1<= k<= (10)^(10^18) (Think of using fermat little theorem)??
3) questions on project written in resume
4) Optimize below code
#define MOD 1000000007
since sum can be very large output sum modulo 10^9+7
and one more coding question was asked.
Round Four: Technical Round (F2F) | Online
Interviewers were helpful. They gave me hints whenever i got stuck in any problem.
1) basic math questions :
how many digits are there in 2^10, 2^32, 2^30, 2^80…??
2) Count number of different balanced bracket sequences can be made using n open brackets and n close brackets. Answer : Catalan number or using Dynamic programming
3) check if given graph can be divided in two cliques and implementation logic. https://www.geeksforgeeks.org/two-clique-problem-check-graph-can-divided-two-cliques/
4) Suppose a curriculum consists of n courses, all of them mandatory. The prerequisite graph G has a node for each course, and an edge from course v to course w if and only if v is a prerequisite for w. Find an algorithm that computes the minimum number of semesters necessary to complete the curriculum and also implement that.
extra question: find minimum number of semester needed if number of courses we have to complete is less than total n courses.
5) Questions on projects written in resume.
7) Length of longest palindrome list in a linked list using O(1) extra space. https://www.geeksforgeeks.org/length-longest-palindrome-list-linked-list-using-o1-extra-space/.
Another method : Convert singly linked list to doubly linked list and find longest palindrome list by considering every index as middle in palindrome list (need to check for two cases odd length palindrome list and even length palindrome list at every index. But i was not allowed to change structure of node of linked list. So i gave an idea of converting singly list to XOR linked list so that i can traverse list in both direction without changing structure of node.
Round Five: HR Round (F2F) | Online
Round lasted for around 15-20 minutes. She asked me normal questions like tell me about yourself, your internship experiences, Why do you want to join this company, What are some activities which make you happy, etc…
At last, she asked me if I have any questions for her. Asking questions to the interviewer is a good sign as it shows your interest in the company.
Although almost all questions were coding questions in each round(tech). I would suggest to make your base strong in other subjects like DBMS, OS, System Design.
Final Verdict: SELECTED