Oracle
90+ 12th Wonder Research Interview Questions and Answers
You are given an array, ‘COORDINATES’ that represents the integer coordinates of some points on a 2D plane. Your task is to find the minimum cost to make all the points connect...read more
You have been given a singly Linked List of 'N' nodes with integer data and an integer 'K'. Your task is to remove the Kth node from the end of the given Linked List.
For example:
The gi...read more
You are given an array 'ARR' of 'N' positive integers. Your task is to find if we can partition the given array into two subsets such that the sum of elements in both subsets is equal....read more
You have been given an integer array/list 'ARR' of size 'N'. Your task is to return the total number of those subsequences of the array in which all the elements are equal.
A subsequence of a ...read more
For a given integer array/list 'ARR' of size 'N', find the total number of 'Inversions' that may exist.
An inversion is defined for a pair of integers in the array/list when the following two co...read more
Q6. Puzzle: – Two persons X and Y are sitting side by side with a coin in each’s hand. The game is to simultaneously flip the coin till anyone wins. Player X will win if he gets a consecutive HEAD, TAIL however Y w...
read moreThe game is not fair.
Player X has a higher chance of winning as they only need to get a consecutive HEAD, TAIL.
Player Y needs to get a consecutive HEAD, HEAD which is less likely to occur.
The probability of Player X winning is higher than Player Y winning.
You're given string ‘STR’ consisting solely of “{“, “}”, “(“, “)”, “[“ and “]” . Determine whether the parentheses are balanced.
Input Format:
The first line contains an Integer 'T' which denot...read more
A lady has 10 bags full of coins. Each bag contains 1000 coins. But one bag is full of forgeries, and she just can’t recall which one. She does know that genuine coins weigh 1 gram, but forgeries weigh 1....read more
You are given a matrix ‘MAT’. Print the transpose of the matrix. The transpose of a matrix is obtained by changing rows to columns and columns to rows. In other words, transpose of a matrix...read more
You have been given ‘K’ different arrays/lists, which are sorted individually (in ascending order). You need to merge all the given arrays/list such that the output array/list should be sor...read more
Q11. In a bag you have 20 black balls and 16 red balls.When you take out 2 black balls you take another white ball.If you take 2 white balls then you take out 1 black ball and if balls are of different color you tak...
read moreThe last ball that will be left is black.
When you take out 2 black balls, you take another white ball.
If you take 2 white balls, you take out 1 black ball.
If balls are of different color, you take out another black ball.
Since there are more black balls initially, the last ball will be black.
You are given a string ‘S’. Your task is to return all distinct palindromic substrings of the given string in alphabetical order.
A string is said to be palindrome if the reverse of the st...read more
You are given two sorted linked lists. You have to merge them to produce a combined sorted linked list. You need to return the head of the final linked list.
Note:
The given linked ...read more
Given the head node of the singly linked list, return a pointer pointing to the middle of the linked list.
If there are an odd number of elements, return the middle element if there are eve...read more
You are given two numbers, ‘X’ and ‘Y’. Your task is to find the greatest common divisor of the given two numbers.
The Greatest Common Divisor of any two integers is the largest number th...read more
You have been given a Binary Tree of distinct integers and two nodes ‘X’ and ‘Y’. You are supposed to return the LCA (Lowest Common Ancestor) of ‘X’ and ‘Y’.
The LCA of ‘X’ and ‘Y’ in the bina...read more
You are given an array ‘ARR’ consisting of 'N' integers, and your task is to sort the given array in non-decreasing order using the Heap sort algorithm.
Input Format:
The first line of the input contai...read more
You are given an N * N matrix of integers where each row and each column is sorted in increasing order. You are given a target integer 'X'. Find the position of...read more
You are given a 'M' x 'N' matrix of characters, 'CHARACTER_MATRIX' and a string 'WORD'. Your task is to find and print all occurrences of the string in the given character matrix. You are al...read more
Given an array ‘pre[]’ of ‘n’ elements that represent Preorder traversal of a spacial binary tree where every node has either 0 or 2 children. Also Given a boolean array ‘i...read more
Pre-requisites: Anagrams are defined as words or names that can be formed by rearranging letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "r...read more
You are given a string EXP which is a valid infix expression. Convert the given infix expression to postfix expression.
Infix expression is of the form a op b. Where operator is is between the o...read more
You are given an array consisting of 0s and 1s. You need to find the length of the largest subarray with an equal number of 0s and 1s.
For example:
If the given ar...read more
Q24. Design a website similar to bookmyshow.com for booking cinema tickets but it must be for a single location only which can have multiple theatres in it. In this he wanted me to design a basic rough GUI, relevant...
read moreDesign a website similar to bookmyshow.com for booking cinema tickets for a single location with multiple theatres.
Design a user-friendly GUI with options for advance booking, user login, user registration, movie rating, and saving card details.
Create relevant database tables to store information about movies, theatres, bookings, user details, and card details.
Link the GUI to the database to enable data flow and retrieval.
Implement features like advance booking, where users c...read more
Q25. Provided a string a character and a count, you have to print the string after the specified character has occurred count number of times. Ex: String: “This is demo string” Character: ‘i’ Count: 3 Output: “ng” H...
read moreThe program prints the substring after a specified character has occurred a certain number of times in a given string.
Iterate through the string to find the specified character.
Keep track of the count of occurrences of the character.
Once the count reaches the specified count, extract the substring after that position.
Handle corner cases such as when the character is not in the string or when it doesn't occur the specified number of times.
Q26. There N rooms in a hotel so customers will check-in and check-out a rooms simultaneously so which type of data structure you implement and it should be efficient and extension of this prebooking will also happe...
read moreTo efficiently manage room bookings and prebookings in a hotel, a priority queue data structure can be implemented.
A priority queue can be used to prioritize room bookings based on check-in dates.
When a customer checks out, the room becomes available and can be assigned to the next customer in the priority queue.
Prebookings can be stored separately and checked against the availability of rooms before assigning them to customers.
The priority queue can be implemented using a bi...read more
Q27. There are five glasses that are kept upside down.At a time you are bound to turn four glasses.Give minimum number of times in which you can turn back all the glasses so that now none among them are upside down
Minimum number of times to turn all glasses upside down when 4 can be turned at a time.
Turn over any four glasses, leaving one untouched.
Repeat the above step until only one glass is left upside down.
Finally, turn over the last glass to complete the task.
Minimum number of turns required is 3.
There are n glasses on the table, all standing upside down. In one move, you are allowed to turn over exactly n – 1 of them. Determine all values of n for which all the glasses can be turned up in the min...read more
Q29. There are 25 horses in which you need to find out the fastest 3 horses. you can conduct a race among at most 5 horses to find out relative speed. At no point, you can find out the actual speed of the horse in a...
read moreMinimum 7 races required to find the top 3 fastest horses.
Divide the 25 horses into 5 groups of 5 horses each.
Conduct a race among the horses in each group to determine the fastest horse in each group.
Take the top 2 horses from each group and conduct a race among them to determine the fastest horse overall.
The winner of this race is the fastest horse.
Now, take the second-place horse from the final race and the second-place horse from each group race.
Conduct a race among these...read more
Q30. There are 25 horses and only 5 horses can be raced at a time and the top 3 are announced in each such race. What is the minimum number of races required to find the top 3 among 25 horses
The minimum number of races required to find the top 3 among 25 horses is 7.
Divide the 25 horses into 5 groups of 5 horses each.
Race the 5 groups, which will give us the top 3 horses from each group.
Now we have 15 horses remaining.
Race the top 3 horses from each group, which will give us the top 3 horses overall.
This requires a total of 7 races.
Q31. Code: – Given the value of a starting position and an ending position, you have to reach from start to end in a linear way, and you can move either to position immediate right to current position or two step ri...
read morePrint all possible paths from start to end in a linear way, moving either one or two steps right.
Use dynamic programming to solve the problem
Create a 2D array to store the number of paths to each position
Start from the end position and work backwards
At each position, calculate the number of paths by summing the number of paths from the next two positions
Print all the paths by backtracking from the start position
You have 10 coins….arrange them in 4 straight lines such that each line contains 4 coins, without picking up the pencil.
Why Java is platform independent and JVM platform dependent?
Write a query that joins two tables A and B having common attribute ID and selects records(ID_NAME) that have matching ID values in both tables .
Q35. What are abstract classes in Java and what is the difference between an abstract class and an interface
Abstract classes in Java are classes that cannot be instantiated and are used as blueprints for other classes.
Abstract classes cannot be instantiated, meaning you cannot create objects of an abstract class.
Abstract classes can have both abstract and non-abstract methods.
Interfaces in Java are similar to abstract classes, but they cannot have any method implementations.
A class can implement multiple interfaces, but it can only extend one abstract class.
Abstract classes can hav...read more
What is the difference between Clustered and Non-clustered index?
Q37. Write a code for inserting two numbers in a text file given n2>n1 and the next entry should not be overlapping like if first was 4,6 next can't be 5,7.the second n1 has to be greater than first n2
The code inserts two numbers in a text file, ensuring that the second number is greater than the first and there is no overlap between entries.
Read the existing entries from the text file
Check if the new numbers satisfy the conditions
If conditions are met, insert the new numbers into the file
Otherwise, display an error message
What do you mean by virtual functions in C++?
What is the major difference b/w 32-bit and 64-bit processors?
What are the differences b/w Mutex and Semaphore?
What is the difference b/w Abstract Class and Interface in Java?
What is the main difference between UNION and UNION ALL?
Q43. What is overloading and what is overriding. Explain each with example
Overloading is when multiple methods have the same name but different parameters. Overriding is when a subclass provides a different implementation of a method inherited from its superclass.
Overloading allows a class to have multiple methods with the same name but different parameters.
Overriding occurs when a subclass provides a different implementation of a method inherited from its superclass.
Overloading is resolved at compile-time based on the method signature.
Overriding i...read more
Explain different types of Normalization forms in a DBMS.
Q45. How is undo operation (ctrl + z) implemented internally?
Undo operation (ctrl + z) is implemented by maintaining a stack of previous states.
When a change is made, the current state is pushed onto the stack
When undo is called, the top state is popped and applied
Redo is implemented by maintaining a stack of undone states
Some applications may also implement a limit on the number of undo/redo steps
Undo/redo can be implemented at different levels (e.g. character, word, paragraph)
Q46. How do you measure 4 liters with a 5 liters and 3 liters container
You can measure 4 liters by following these steps:
Fill the 5 liters container completely
Pour the 5 liters into the 3 liters container, leaving 2 liters in the 5 liters container
Empty the 3 liters container
Pour the remaining 2 liters from the 5 liters container into the 3 liters container
Fill the 5 liters container again
Pour 1 liter from the 5 liters container into the 3 liters container, which now has 3 liters
The 5 liters container now has 4 liters
Q47. to explain algorithm of the project that I’m going to do in the upcoming semester and asked me code it
The algorithm for the upcoming semester project involves developing an application.
Identify the requirements and objectives of the project
Design the application architecture and user interface
Implement the necessary algorithms and data structures
Test and debug the application
Optimize the performance and efficiency of the code
Document the project for future reference
Q48. Write code to find the middle element of a linked list
Code to find the middle element of a linked list
Traverse the linked list with two pointers, one moving twice as fast as the other
When the fast pointer reaches the end, the slow pointer will be at the middle element
If the linked list has even number of elements, return the second middle element
Q49. Write a code to count the number of times '1' occurs from 1 to 999999
Code to count the number of times '1' occurs from 1 to 999999
Loop through all numbers from 1 to 999999
Convert each number to a string and count the number of '1's in it
Add the count to a running total
Return the total count
Q50. Given a matrix.Write a code to print the transpose of the matrix
The code prints the transpose of a given matrix.
Iterate through each row and column of the matrix.
Swap the elements at the current row and column with the elements at the current column and row.
Print the transposed matrix.
Given an Employee Table, find the Nth highest salary from it.
What are Constraints in SQL?
Given an Employee Table, find the Nth highest salary from it.
Q54. Find the common ancestor of two given nodes in a tree
Find the common ancestor of two given nodes in a tree
Traverse the tree from the root node
Check if both nodes are on the same side of the current node
If not, return the current node as the common ancestor
If yes, continue traversing down that side of the tree
Explain the difference between the DELETE and TRUNCATE command in a DBMS.
Q56. What is time complexity of 8 queens algorithm
The time complexity of 8 queens algorithm is O(n!).
The algorithm checks all possible permutations of the queens on the board.
The number of permutations is n! where n is the number of queens.
For 8 queens, there are 8! = 40,320 possible permutations.
The algorithm has to check each permutation to find a valid solution.
Therefore, the time complexity is O(n!).
Q57. Puzzle: Gi1ven 4 coins, arrange then to make maximum numbers of triangle of the figure
Arrange 4 coins to make maximum number of triangles
Place 3 coins in a triangle formation and the fourth coin in the center to form 4 triangles
Place 2 coins on top of each other and the other 2 coins on either side to form 2 triangles
Place 2 coins in a line and the other 2 coins on either side to form 2 triangles
Q58. What is your favorite program and why is it so
My favorite program is Visual Studio Code because of its user-friendly interface and extensive plugin library.
User-friendly interface with customizable settings
Extensive plugin library for various programming languages and tools
Integrated terminal and debugging features
Supports Git version control
Frequent updates and improvements
Free and open-source
Examples: Python, JavaScript, HTML/CSS, Git
Q59. Puzzle: Given 10 coins, arrange them such that we get 4 different rows each containing 4 coins
Arrange 10 coins in 4 rows of 4 coins each.
Place 4 coins in a row and keep the remaining 6 aside.
Place 3 coins from the remaining 6 in the next row and keep the remaining 3 aside.
Place 2 coins from the remaining 3 in the third row and keep the remaining 1 aside.
Place the last coin in the fourth row along with the remaining 1 coin from step 3.
The final arrangement will have 4 rows with 4 coins each.
Explain Method Overloading and Method Overriding.
Q61. Programs like count the frequency of every alphabet in a string
Count the frequency of each alphabet in a string.
Iterate through the string and count the occurrence of each alphabet using a dictionary or array.
Convert the string to lowercase or uppercase to avoid case sensitivity.
Exclude non-alphabetic characters using regular expressions.
Consider using built-in functions or libraries for efficiency.
Handle edge cases such as empty strings or strings with no alphabetic characters.
Explain multitasking and multiprogramming.
Q63. Find the number of palindromes in a big string
Count the number of palindromes in a given string.
A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward.
Iterate through the string and check if each substring is a palindrome.
Use two pointers, one at the beginning and one at the end of the substring, and move them towards each other until they meet in the middle.
If the substring is a palindrome, increment the count.
Consider both even and odd length palindromes.
Q64. Find the fifth largest element in a linked list
Find the fifth largest element in a linked list
Traverse the linked list and store the elements in an array
Sort the array in descending order
Return the fifth element in the sorted array
Q65. Explain multitasking and multiprogramming
Multitasking is the ability of an operating system to run multiple tasks concurrently while multiprogramming is the ability to run multiple programs concurrently.
Multitasking allows multiple tasks to run concurrently on a single processor system.
Multiprogramming allows multiple programs to run concurrently on a single processor system.
Multitasking is achieved through time-sharing, where the processor switches between tasks at a very high speed.
Multiprogramming is achieved thr...read more
Q66. Find the maximum salary in emp table
To find the maximum salary in emp table, use the MAX function on the salary column.
Use the MAX function in SQL to find the highest value in a column
Specify the column name after the MAX function, in this case 'salary'
Example: SELECT MAX(salary) FROM emp
This will return the highest salary value in the emp table
Q67. What are ER diagrams for?
ER diagrams are used to visualize and design relational databases.
ER diagrams show the relationships between entities in a database
They help in identifying the attributes of each entity
They aid in designing the structure of a database
ER diagrams are commonly used in software development
Q68. Design circular doubly linked list with all operations.
Circular doubly linked list is a data structure where each node has a reference to both the next and previous nodes, forming a circular loop.
Create a Node class with data, next, and prev pointers
Implement operations like insert, delete, search, and display
Ensure the last node's next pointer points to the first node and the first node's prev pointer points to the last node
Q69. Different types of searching and sorting algo discussion.
Searching and sorting algorithms are essential in programming for efficiently organizing and retrieving data.
Searching algorithms: linear search, binary search, depth-first search, breadth-first search
Sorting algorithms: bubble sort, selection sort, insertion sort, merge sort, quick sort
Examples: Searching for a specific item in a list, sorting a list of numbers in ascending order
Q70. Write code for Towers of Hanoi problem
Towers of Hanoi is a classic problem of moving disks from one peg to another with specific rules.
The problem involves three pegs and a number of disks of different sizes.
The goal is to move all the disks from the first peg to the third peg, while following the rules.
The rules are: only one disk can be moved at a time, a larger disk cannot be placed on top of a smaller disk, and all disks must be moved to the third peg.
The solution can be implemented recursively.
Example code: ...read more
Q71. Explain three normalizations with example
Explanation of three normalizations with examples
First Normal Form (1NF): Eliminate duplicate data and create separate tables for related data
Example: A table with customer information and their orders should be split into two tables
Second Normal Form (2NF): Ensure non-key attributes are dependent on the primary key
Example: A table with customer information and their orders should have separate tables for customer and order details
Third Normal Form (3NF): Eliminate transitive...read more
Q72. Find the duplicates in an array
Find duplicates in an array
Iterate through the array and compare each element with the rest of the elements
Use a hash table to keep track of the frequency of each element
Sort the array and compare adjacent elements
Use a set to keep track of unique elements and add duplicates to another set
Q73. Difference between semaphore and mutex
Semaphore allows multiple threads to access shared resources at the same time, while mutex allows only one thread at a time.
Semaphore is used to control access to a resource with limited capacity, like a printer or database connection pool.
Mutex is used to protect a shared resource from simultaneous access, like a critical section of code.
Semaphore can have a count greater than 1, allowing multiple threads to access the resource simultaneously.
Mutex has a binary state, either...read more
Q74. Implement queue using linked lists
Implementing queue using linked lists
Create a Node class with data and next pointer
Create a Queue class with head and tail pointers
Enqueue by adding a new node at the tail and dequeue by removing the head node
Check for empty queue by checking if head is null
Q75. minimum area of square that contains all the points
The minimum area of a square that contains all given points is the square of the maximum distance between any two points.
Calculate the distance between all pairs of points
Find the maximum distance
Square the maximum distance to get the minimum area of the square
Q76. design hashmap from scratch
Designing a hashmap from scratch
A hashmap is a data structure that allows for efficient key-value pair storage and retrieval
It typically uses an array and a hashing function to map keys to array indices
Collision handling techniques like chaining or open addressing may be used
Operations like insert, delete, and search can be implemented using the hashmap
Example: Designing a hashmap to store student records with their roll numbers as keys
Q77. Largest element in window size K
Find the largest element in a window of size K in an array.
Iterate through the array and maintain a deque to store the indices of elements in decreasing order.
Remove indices from the front of the deque that are outside the current window.
The front of the deque will always have the index of the largest element in the current window.
Q78. Merge two sorted linked lists
Merge two sorted linked lists
Create a new linked list to store the merged list
Compare the first nodes of both lists and add the smaller one to the new list
Move the pointer of the added node to the next node
Repeat until one of the lists is empty, then add the remaining nodes to the new list
Q79. Explain 8 queens algorithm
8 Queens Algorithm is a backtracking algorithm to place 8 queens on a chessboard without attacking each other.
The algorithm places one queen in each column, starting from the leftmost column.
If a queen can be placed in a row without attacking another queen, it is placed there.
If no such row exists, the algorithm backtracks to the previous column and tries a different row.
The algorithm continues until all 8 queens are placed on the board without attacking each other.
The algori...read more
Q80. Explain interfaces in Java
Interfaces in Java define a contract for classes to implement certain methods.
Interfaces are like a blueprint for classes to follow
They can contain method signatures but no implementation
Classes can implement multiple interfaces
Interfaces can extend other interfaces
Example: Comparable interface for sorting objects
Q81. Maximum length of subarray of given sum
Find the maximum length of a subarray with a given sum in an array.
Use a hashmap to store the running sum and its corresponding index.
Iterate through the array and update the hashmap with the running sum.
Check if the difference between the current sum and the target sum exists in the hashmap to find the subarray length.
Q82. Traversing singly linked list
Traversing a singly linked list involves iterating through each node starting from the head node.
Start at the head node
Iterate through each node by following the 'next' pointer
Stop when reaching the end of the list (next pointer is null)
Q83. Explain heap sort
Heap sort is a comparison-based sorting algorithm that uses a binary heap data structure.
It divides the input into a sorted and an unsorted region.
It repeatedly extracts the largest element from the unsorted region and inserts it into the sorted region.
It has a worst-case and average-case time complexity of O(n log n).
Q84. Reverse a string
Reverse a string
Use a loop to iterate through the string and append each character to a new string in reverse order
Alternatively, use the built-in reverse() method for strings in some programming languages
Q85. sum 2 linkedlists in efficient way
Use iterative approach to traverse both linked lists and sum corresponding nodes while keeping track of carry.
Iterate through both linked lists simultaneously
Sum corresponding nodes and carry from previous sum
Create a new linked list to store the sum
Q86. Hotel booking system design
Design a hotel booking system.
Create a database to store hotel information, room availability, and bookings.
Develop a user interface for customers to search and book hotels.
Implement a payment gateway for secure transactions.
Include features like room selection, date selection, and guest information.
Consider implementing a rating and review system for hotels.
Ensure the system can handle concurrent bookings and prevent double bookings.
Q87. Sql query using joins
SQL query using joins
Use JOIN keyword to combine rows from two or more tables based on a related column between them
Types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN
Example: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column
Q88. Merge two sorted arrays
Merge two sorted arrays into a single sorted array
Create a new array to store the merged result
Use two pointers to iterate through both arrays and compare elements
Add the smaller element to the new array and move the pointer for that array
Q89. Shallow copy vs Deep copy
Shallow copy only copies the references of objects, while deep copy creates new copies of objects.
Shallow copy creates a new object but does not create copies of nested objects.
Deep copy creates new copies of all nested objects.
Shallow copy is faster and more memory efficient, but changes to nested objects affect both copies.
Deep copy is slower and uses more memory, but changes to nested objects do not affect the original object.
Q90. Design Tic Tac Toe
Design a Tic Tac Toe game
Create a 3x3 grid to represent the game board
Allow two players to take turns marking X and O on the grid
Check for win conditions after each move to determine the winner
Handle tie game if all spaces are filled without a winner
Q91. Find area using co ordinates
Calculate the area of a shape using coordinates
Determine the type of shape (e.g. rectangle, triangle, circle)
Use the appropriate formula for the shape to calculate the area
Input the coordinates into the formula to get the area
Q92. Intersection of linked list
Intersection of linked list is finding the common node where two linked lists merge.
Traverse both linked lists to find their lengths
Align the longer list's pointer to match the length of the shorter list
Iterate through both lists simultaneously to find the intersection node
More about working at Oracle
Top HR Questions asked in 12th Wonder Research
Interview Process at 12th Wonder Research
Top Application Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month