Started with a HackerRank 90 minute coding test that had three questions. Recruiter told me that passing marks were 60 out of 100. However, the difficulty of the questions increased and third question was the hardest. I solved all of them however, the runner code for first question had error and I couldn't run it. When I reached out to the recruiter about it she told me that I passed even without it and moved me to a four hour virtual onsite.
The onsite interview had two coding rounds, one system design and one behavioral round with hiring manager. First interviewer didn't seem too interested and felt like a robot person. She asked me to open the coderpad URL and also share my screen. First question was “Given an array of unique non-negative integers, {A1,…,An}, and a positive integer, X, write a function that finds all pairs of numbers in the array that sum to X”.
My implementation was:
public int method(int[] array, int sum) {
int result = 0;
if (array.length() <= 1) {
return 0;
}
for (int i = 0; i <= array.length(); i++) {
for (int j = i + 1; j < array.lenght(); j++ {
if (array[i] + array[j] == sum) {
result++;}}}
return result;
}
I solved this in 15-20 minutes however, initially forgot to put in second forloop. Interviewer asked how second number is being checked and upon that I added it in. Her second question was “Take a singly-linked list, and reorder in such a way that the first element points to the last element, second element points to second-to-last element, and so on.
Since I only had 20 minutes left, I started designing the algorithm in pseudo code. After I knew I had an algorithm, I started coding it but we ran out of time.
The second coding interview was with another engineer on the team and he seemed pretty friendly. Started asking about my past experience, and where I worked. I previously worked at Expedia and he asked about that. After 10 minute of conversation he moved to coding question and asked “You are given an integer array nums sorted in ascending order (with distinct values), and an integer target. Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).”
I initially started with a very basic brute force implementation. He then asked that if I could make it better with the fact that array is sorted. I told him that I could do a binary search, again started with a pseudo code algorithm and was able to code it. Checked my code later in IDE and it worked. Below was my implementation.
public int method(int[] nums, int target) {
// return if nums is null or its length is 0
if (nums == null || nums.length == 0) {
return -1;}
int pivot = nums.length - 1;
while (pivot > 0 && nums[pivot - 1] < nums[pivot]) {
pivot--;}
if (pivot == 0) {
return binarySearch(nums, 0, nums.length, target);}
int start; int end;
if (target == nums[pivot]) {
return pivot;
} else if (target >= nums[0] && target <= nums[pivot - 1]) {
start = 0;
end = pivot;
} else { // find target in the second part
start = pivot;
end = nums.length;}
return binarySearch(nums, start, end, target);}
private static int binarySearch(int[] nums, int start, int end, int target) {
int i = start;
int j = end - 1;
while (i <= j) {
int mid = (i + j) / 2;
if (target > nums[mid]) {
i = mid + 1;
} else if (target < nums[mid]) {
j = mid - 1;
} else {
return mid;} }
return -1;}}
This took about 40 minutes to solve it entirely. He asked few questions about algorithm and then asked me if I had any questions.
Then the hiring manager came and asked about behavorial questions. This was mostly conversation style interview. She seemed friendly too. Last was system design and I was asked to design a chat app. Interviewer was also very friendly and liked my implementation.
Then about two weeks later recruiter called and told me that team has decided to move forward with someone else but what she told me didn’t make sense. She told me that one interviewer said I was struggling with the algorithm. This could be the second question of the first round, however, I wasn’t struggling. I had the algorithm, just not enough time to complete it. She said that the other person said that he couldn’t ask second question, but this is totally wrong as the second interviewer specifically said he only had one question. I think either they confused me with someone else or didn’t give the feedback properly. I saved my code, ran them in my IDEs post interview and they worked.
Experience wise, I enjoyed the process. The first interviewer wasn’t friendly at all but rest of them made the experience good. Good luck to you a