Interviewer had a look at my resume and asked about my current project and technology stack that I am familiar with. After that she asked me to solve a coding problem.
Question 1 :
Given an array of Integers which is the level order traversal of a binary tree, And asked me to find out whether it is a binary search tree or not.
Examples :
Input : [8,5,11,null,null,10,12,7,null]
Output : False

Input : [8,5,13,null,null,10,16,9,14]
Output : False

Input : [8,5,13,null,null,10,16,9,11]
Output : True

Before I start coding, she was interested in the approach. I took some time and came up with an approach and she was satisfied with approach and asked me to code. Tested my code on some test cases by making sure every test case got passed and she moved to next question.
Question 2 :
Given a string containing Integers. Find the number of ways in which we can decode the string into upper case English alphabets. Assume 'A' stands for 1 and 'B' stands for 2 …..'Z' stands for 26.
Examples :
Input : "226"
Output : 3
Possible combinations : BZ(2, 26), VF(22, 6), BBF(2,2,6)
Input : "100"
Output : 0
Input : "205"
Output : 1
Possible Combinations : TE
I have implemented using recursion and dynamic programming (to avoid re-computing same sub-problems). She tested the code with some test cases and edge cases as well and asked me the complexity of the program if I haven't used dynamic programming. I answered it as O(2^n). She said that this was the last question in this round and wished me best of luck for the second round which will start in 15 mins.
Interviewer asked about my current project and tech stack that I am using. Then he asked some question on core Java which are as follows
After me answering these questions, he gave me some coding problems which are as follows
Question 1 :
Given an array write a program to detect duplicates.
Examples :
Input : [1,2,37,56, 2]
Output : False
Input : [1,2,37,56, 87]
Output : True
Suggested multiple approaches and coded it by using a hash set after which he tested the code with some test cases and moved to second question
Question 2 :
Assume there are 100, 500, 1000 rupee denominations available in an ATM in limited number. Write a program to dispense minimum number of notes for each transaction and you are allowed to dispense maximum of 40 notes per transaction.
Examples :
Input : [[100, 2], [500, 3], [1000, 4]], 4000
Output : 4
Input : [[100, 2], [500, 3], [1000, 5]], 10000
Output : "cannot dispense"
After completing the coding part he tested the code with some test cases and promoted me to third round which will start in another 10 mins.
Interviewer started asking about my current project, the reason why I am looking for a Job change, and why oracle. After me answering these questions, he started asking about some core Java questions as described below
After these he gave me some coding questions as below
Question 1 :
Write a function which should take swagger file as an input and print all the endpoints with parameters
Example :
Input : org.json.JSONObject swagger
Output :
"/v1/postFunction"
["body", "token", "object"]
"/v1/getFunction"
["parameter", "token"]
"/v1/putFunction"
["body", "token", "object"]
For those of you unfamiliar with "Swagger file". Have a look at it here I have tried this but couldn't code it as there were some exceptions, interviewer observed that I am struggling for this and asked me to stop. We moved to next question
Question 2 :
Write a function which should take large string as an input and prints top k frequent characters. Note : 'A' and 'a' are considered different and there may be special characters like '@' and '!' etc. in the string provided as input.
Example :
Input : "", k=3
Output :
Character is e count is 2
Character is @ count is 2
Character is $ count is 2
Used HashMap to store character and its frequency, comparator to sort in descending order and printed first k entries after the sort. Round 3 ended at 8:00 PM in the evening, where Round 1 had started at around 2:00 PM. Interviewer said "I think you are exhausted Go and take some rest. We will evaluate your profile and come back to you".
After 2 days I have received a call for 4th round.
As usual, Interviewer went through my resume and asked about my current project and technology stack that I am familiar with. Asked my current CTC, expected CTC, why do you want to change and why Oracle? After me answering all these question he asked me to code a real business use case, which is as follows
Question 1 :
There is a manufacturer who manufactures bikes, cars, washing machines, AC's etc. Bikes contain Engine, Gas Tank, Seat, Hand clutch, Brake Rod, Oil tank, Foot Rest, Starter Pedal, Rear Wheel, Exhaust pipes, Brake cable, Headlight, speedometer, Horn, Exhaust Pipe, Mirrors, License plate, Tail Light and each of the above part is an complex structure For e.g. Engine contains screws, nuts, oil feed pipe, Inlet pipe, oil pump, cylinder head, exhaust post, cylinder head, cooling fin, piston etc.. Same goes with cars, washing machine, AC's etc..
By the time he explained all the machines from bikes to AC's and all the parts and sub parts and sub sub parts..., I am going mad and gave a smile. After which he stopped explaining these parts and sub parts stuff And asked me to write a program which takes two components as input and return how many components of second argument are required to make first component. I know by the time you read this you are going crazy, Let me give you an example to explain what I need to code exactly.
Example :
Input : Bike, Wheels
Output : 2
2 wheels are required in the process of manufacturing the Bike
Input : Bike, Nuts
Output : 500
500 nuts are required in the process of manufacturing the Bike
Input : Nuts, Bike
Output : 0
As no Bikes are required in the process of manufacturing the Nut.
Note : Your code should be very generic. So that if manufacturer manufactures a new product ten years down the line let's say cooler, he should not come back to you for any modifications in your function.
To be honest, I am blank for the first 20 mins and then suddenly an Idea sparked and I started implementing it using trees. I was not sure on how to represent the data in a generic way. First he asked me about the Data Structure on how I am representing the data. Once I have shown him my Component class(See Below) he seems to be convinced and asked me to Code the logic. Once I am done with my coding he gave some test cases and asked to check what my program returns. Attaching a raw template of the code below
import java.io.*;
class LeetCode {
class Component {
int number;
String name;
List<Component> components;
}
public int findComponents(Component input, Component output) {
int count = 0;
//if output can be made from input component
if(input.name.equals(output.name)) {
return input.number;
}
//if input is a leaf
if(input.components == null) {
return 0;
}
//iterate the list of components
for(Component temp : input.components) {
//see if how many output components can be made from temp
count = count + findComponents(temp, output);
}
return count*(input.number);
}
}Puzzle :
Given two container's of 5 and 3L and tap with infinite supply of water. How do you measure 4L of water?
After me answering that puzzle he asked whether I had any questions for him or not, I asked him to share something about the role, team that I will be joining If I am selected and also asked him to share one of his most memorable Aha moments in Oracle.
Overall It was a good experience, Rounds 1, 3, 4 are challenging for me which may vary from person to person. Several Out of the box questions were asked in Round 3(Swagger) & Round 4 (manufacturing).