Related Articles

# Oracle Interview Experience

• Difficulty Level : Hard
• Last Updated : 30 Mar, 2021

The 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 the 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 the 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 the 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 the best of luck for the second round which will start in 15 mins.

The interviewer asked about my current project and the tech stack that I am using. Then he asked some question on core Java which are as follows

1. Why we use gateway’s in Microservices
2. Significance of volatile keyword

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 by using a hash set after which he tested the code with some test cases and moved to the second question

Question 2: Assume there are 100, 500, 1000 rupee denominations available in an ATM in a limited number. Write a program to dispense a minimum number of notes for each transaction, and you are allowed to dispense a 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 my coding he tested the code with some test cases and promoted me to the third round which will start in another 10 mins.

The 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

1. Significance of volatile keyword
2. Difference between comparator and comparable
3. Difference between StringBuffer and StringBuilder, And asked why Java started using StringBuilder from JDK 1.5 instead of StringBuffer
4. Significance of static variables
5. Significance of Final class, final variables.
6. Significance of Synchronized keyword

After these, he gave me some coding questions as below

Question 1: Write a function that should take a 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(https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/json/uber.json) I have tried this but couldn’t code it as there were some exceptions, the interviewer observed that I am struggling with this and asked me to stop. We moved to the next question

Question 2: Write a function that should take a large string as an input and print 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 : "\$geeksforGEEKs@", k=3
Output :
Character is e count is 2
Character is E count is 2
Character is s count is 2```

Used HashMap to store character and its frequency, comparator to sort in descending order, and printed the first k after the sort. Round 3 ended at 8:00 PM, where Round 1 had started at 2:00 PM. The 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, the 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 questions 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 a 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 machines, 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 that takes two components as input and return how many components of the second argument are required to make the 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 the 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 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 me to check what my program returns. Attaching a raw template of the code below

## Java

 `/*package whatever //do not write package name here */`` ` `import` `java.io.*;`` ` `class` `GFG {``  ``class` `Component {``        ``int` `number;``        ``String name;``        ``List 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 :

1. Given two containers of 5 and 3L and tap with an infinite supply of water. How do you measure 4L of water?
2. 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 and also asked him to share one of his most memorable Ahaa moments in Oracle.
3. Overall It was a good experience, Rounds 1, 3, 4 are challenging for me which may vary from person to person. Several Out of box questions were asked in Round 3(Swagger) & Round 4 (manufacturing)

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon. GoogleE-Litmus and Microsoft Test Serieses.

My Personal Notes arrow_drop_up