Oracle Previous year coding questions 2025
Oracle, a global leader in database software, cloud solutions, and enterprise applications, is renowned for its cutting-edge technologies like Oracle Database, Oracle Cloud Infrastructure, and Java-based solutions. Headquartered in Austin, Texas, Oracle employs thousands of professionals worldwide, offering roles such as Software Engineer, Applications Engineer, and Database Administrator. Landing a job at Oracle is a dream for many tech enthusiasts due to its reputation for innovation, competitive salaries, and opportunities to work on impactful projects.
In this blog, we’ll dive into Oracle’s hiring process, provide insights into the types of coding questions asked in their interviews, and share a curated list of past-year questions (PYQs) to help you prepare effectively. This guide is optimized for those searching for “Oracle coding interview questions,” “Oracle hiring process,” or “Oracle past year coding questions” to boost your preparation and confidence.
Oracle’s Hiring Process: What to Expect
Oracle’s recruitment process typically involves multiple stages, tailored to assess a candidate’s technical expertise, logical reasoning, and cultural fit. Below is an overview of the typical hiring process for technical roles:
1- Online Application: Candidates apply through Oracle’s career portal, job platforms, or campus recruitment drives. Ensure your resume highlights relevant skills like programming (C++, Java, Python), data structures, algorithms, and SQL/PL-SQL.
2- Online Coding Assessment: This is the first technical filter, usually conducted on platforms like CodeStreet, HackerRank, or Oracle’s proprietary system. The test includes:
- Coding Questions: 2-4 problems focusing on data structures (arrays, linked lists, trees), algorithms (sorting, searching, dynamic programming), and sometimes SQL queries.
- MCQs: Questions on programming concepts, DBMS, operating systems, and aptitude.
- Duration: Typically 60-120 minutes.
- Difficulty: Easy to medium for freshers, with one or two challenging problems for experienced candidates.
3- Technical Interviews: Shortlisted candidates face 2-3 rounds of technical interviews, which may be virtual or in-person. These rounds assess:
- Coding Skills: Live coding or whiteboard problems similar to those in the online test.
- System Design (for senior roles): Designing scalable systems or database solutions.
- Core Concepts: Deep dives into data structures, algorithms, DBMS, and programming languages like Java or Python.
4- HR Interview: The final stage evaluates soft skills, cultural fit, and career aspirations. Be prepared to discuss your projects, Oracle’s technologies, and why you want to join the company.
5- Offer: Successful candidates receive an offer, with Oracle known for competitive packages and benefits.
Key Skills Tested
Oracle’s coding rounds emphasize:
- Data Structures: Arrays, Strings, Linked Lists, Stacks, Queues, Trees, Graphs.
- Algorithms: Sorting, Searching, Greedy, Dynamic Programming, Backtracking.
- Programming Languages: C, C++, Java, Python (Java is often preferred due to Oracle’s ecosystem).
- Database Skills: SQL, PL-SQL, query optimization.
- Problem-Solving: Logical reasoning and mathematical computations.
Apply for Oracle Jobs from here - Oracle Career Page
Oracle HR Details on Linkedin, connect for job enquiry - Oracle HR's
Curated List of Oracle’s Past Year Coding Questions
Below is a detailed list of problem statements commonly associated with Oracle’s previous year coding questions, focusing on the types of problems asked in their recruitment drives. Each problem includes a detailed description, input/output format, constraints, and example, tailored to help you prepare effectively.
- Maximum Profit from Stock Prices
Description: Ratan is a wealthy investor who wants to maximize profits by buying and selling stocks. Given a list of stock prices for several days, calculate the maximum profit that can be achieved by buying at a low price on one day and selling at a high price on a later day. If no profit is possible, return 0.
Input Format:- First line: An integer
n
, representing the number of days (1 ≤ n ≤ 10^5). - Next
n
lines: An integer representing the stock price for each day (0 ≤ price ≤ 10^6).
Output Format: A single integer representing the maximum profit possible.
Constraints: - 1 ≤ n ≤ 10^5
- 0 ≤ price ≤ 10^6
Example:Input: 7 1 9 2 11 1 9 2 Output: 10
Explanation: Buy on day 1 (price = 1) and sell on day 4 (price = 11) for a profit of 11 - 1 = 10.
- First line: An integer
- Bank Loan Interest Comparison
Description: You are offered loans from two banks, each with different interest rates applied over specific periods (slabs). Calculate the total interest paid for each bank based on the EMI formula:EMI = loanAmount * monthlyInterestRate / (1 – 1 / (1 + monthlyInterestRate)^(numberOfYears * 12))
. Determine which bank offers the lower total interest.
Input Format:- First line: A double
P
, the principal amount (1000 ≤ P ≤ 10^6). - Second line: An integer
T
, the tenure in years (1 ≤ T ≤ 20). - Third line: An integer
N1
, the number of slabs for Bank A (1 ≤ N1 ≤ T). - Next
N1
lines: Two values, an integerperiod
(years) and a doublerate
(interest rate in %). - Next line: An integer
N2
, the number of slabs for Bank B (1 ≤ N2 ≤ T). - Next
N2
lines: Two values, an integerperiod
(years) and a doublerate
(interest rate in %).
Output Format: A string, either "Bank A" or "Bank B", indicating the bank with lower total interest.
Constraints: - 1000 ≤ P ≤ 10^6
- 1 ≤ T ≤ 20
- 1 ≤ N1, N2 ≤ T
- 0.1 ≤ rate ≤ 20.0
Example:Input: 10000 20 3 5 9.5 10 9.6 5 8.5 3 10 6.9 5 8.5 5 7.9 Output: Bank B
Explanation: Bank B’s total interest, calculated using the EMI formula for each slab, is lower than Bank A’s.
- First line: A double
- Borrow Operations for Subtraction
Description: Given two numbers represented as strings, determine the number of borrow operations required to subtractnumber2
fromnumber1
using standard subtraction rules. If subtraction is not possible (e.g.,number2
is larger), output "Not possible".
Input Format:- First line: A string
number1
(the minuend). - Second line: A string
number2
(the subtrahend).
Output Format: An integer representing the number of borrow operations, or "Not possible" if subtraction cannot be performed.
Constraints: - 1 ≤ length of
number1
,number2
≤ 100 number1
andnumber2
contain only digits (0-9).
Example:Input: 754 658 Output: 2
Explanation: Subtracting 658 from 754 requires borrowing twice: once for the units place (4 < 8) and once for the tens place (5 < 5 after borrowing).
- First line: A string
- Count Distinct Elements in a Range
Description: Given an array of integers, find the number of distinct elements within a specified range[l, r]
(1-based indexing).
Input Format:- First line: An integer
n
, the size of the array (1 ≤ n ≤ 10^5). - Second line:
n
integers representing the array elements (0 ≤ elements ≤ 10^6). - Third line: Two integers
l
andr
, the range (1 ≤ l ≤ r ≤ n).
Output Format: An integer representing the number of distinct elements in the range[l, r]
.
Constraints: - 1 ≤ n ≤ 10^5
- 0 ≤ elements ≤ 10^6
- 1 ≤ l ≤ r ≤ n
Example:Input: 5 1 2 2 3 4 1 3 Output: 3
Explanation: In the range [1, 3], the elements are [1, 2, 2], with 3 distinct values: 1, 2, and 3 (since 2 appears twice).
- First line: An integer
- Sort Colors (Dutch National Flag Problem)
Description: Given an array of integers representing colors (0 for red, 1 for white, 2 for blue), sort the array such that all 0s come first, followed by all 1s, and then all 2s, in a single pass if possible.
Input Format:- First line: An integer
n
, the size of the array (1 ≤ n ≤ 10^5). - Second line:
n
integers, each being 0, 1, or 2.
Output Format: A single line containing the sorted array, with elements separated by spaces.
Constraints: - 1 ≤ n ≤ 10^5
- Each element is 0, 1, or 2.
Example:Input: 5 2 0 1 2 0 Output: 0 0 1 2 2
Explanation: The array is sorted with all 0s first, then 1s, then 2s.
- First line: An integer
- Network Stream (Largest Repackaged Packet)
Description: A server receives a stream ofn
data packets, but it can only process packets of sizes that are powers of 2 (e.g., 1, 2, 4, 8, ...). Each packet is repackaged to the largest possible power of 2 size, and any remaining portion is added to the next packet. Find the size of the largest repackaged packet across the stream.
Input Format:- First line: An integer
n
, the number of packets (1 ≤ n ≤ 10^5). - Next
n
lines: An integer representing the size of each packet (1 ≤ size ≤ 10^9).
Output Format: An integer representing the size of the largest repackaged packet.
Constraints: - 1 ≤ n ≤ 10^5
- 1 ≤ size ≤ 10^9
Example:Input: 5 13 25 10 2 8 Output: 16
Explanation: Packet sizes are repackaged to the largest power of 2 (e.g., 13 → 8, remainder 5 added to next packet). The largest repackaged size is 16.
- First line: An integer
- Distinct Numbers in Multiple Ranges
Description: Given an array ofn
integers andm
queries, for each queryli
, find the number of distinct numbers in the subarray from indexli
to the end of the array (1-based indexing).
Input Format:- First line: Two integers
n
(array size) andm
(number of queries) (1 ≤ n, m ≤ 10^5). - Second line:
n
integers representing the array elements (1 ≤ elements ≤ 10^6). - Next
m
lines: An integerli
, the starting index of the range (1 ≤ li ≤ n).
Output Format:m
lines, each containing an integer representing the number of distinct elements in the range fromli
ton
.
Constraints: - 1 ≤ n, m ≤ 10^5
- 1 ≤ elements ≤ 10^6
- 1 ≤ li ≤ n
Example:Input: 10 10 1 2 3 4 1 2 3 4 100000 99999 1 2 3 4 5 6 7 8 9 10 Output: 6 6 6 6 6 5 4 3 2 1
Explanation: For each queryli
, count distinct elements from indexli
to the end. Forli = 1
, the subarray is [1, 2, 3, 4, 1, 2, 3, 4, 100000, 99999], with 6 distinct values.
- First line: Two integers
- Biggest Meatball
Description: In a hiring process,N
people bring meatballs of varying weights. Each day,D
grams are cut from the first meatball in a queue. If its weight becomes zero or less, it is removed; otherwise, it is moved to the end of the queue. This process repeats until only one meatball remains. Find the weight of the last remaining meatball.
Input Format:- First line: Two integers
N
(number of meatballs) andD
(grams cut each day) (1 ≤ N ≤ 10^5, 1 ≤ D ≤ 10^9). - Second line:
N
integers representing the weights of the meatballs (1 ≤ weight ≤ 10^9).
Output Format: An integer representing the weight of the last remaining meatball.
Constraints: - 1 ≤ N ≤ 10^5
- 1 ≤ D, weight ≤ 10^9
Example:Input: 4 2 5 2 4 1 Output: 1
Explanation: After cutting 2 grams each day and moving non-zero meatballs to the end, the last meatball remaining has weight 1.
- First line: Two integers
- Merge Two Sorted Arrays
Description: Given two sorted arrays of sizesm
andn
, merge them into a single sorted array without using extra space beyond what is necessary for the output.
Input Format:- First line: Two integers
m
andn
, the sizes of the two arrays (1 ≤ m, n ≤ 10^5). - Second line:
m
integers representing the first sorted array (1 ≤ elements ≤ 10^6). - Third line:
n
integers representing the second sorted array (1 ≤ elements ≤ 10^6).
Output Format: A single line containing the merged sorted array, with elements separated by spaces.
Constraints: - 1 ≤ m, n ≤ 10^5
- 1 ≤ elements ≤ 10^6
Example:Input: 3 3 1 3 5 2 4 6 Output: 1 2 3 4 5 6
Explanation: The merged array contains all elements from both arrays in sorted order.
- First line: Two integers
- Reverse a Linked List
Description: Given a singly linked list of integers, reverse the list and return the new head. The input is provided as a sequence of integers ending with -1 to indicate the end of the list.
Input Format:- A single line containing integers representing the linked list nodes, followed by -1 (1 ≤ value ≤ 10^4).
Output Format: A single line containing the integers of the reversed linked list, separated by spaces.
Constraints: - 1 ≤ number of nodes ≤ 10^5
- 1 ≤ value ≤ 10^4
Example:Input: 1 2 3 4 5 -1 Output: 5 4 3 2 1
Explanation: The linked list 1->2->3->4->5 is reversed to 5->4->3->2->1.
- A single line containing integers representing the linked list nodes, followed by -1 (1 ≤ value ≤ 10^4).
- Longest Common Subsequence
Description: Given two strings, find the length of the longest common subsequence (a subsequence is a sequence of characters that can be derived by deleting some or no elements without changing the order).
Input Format:- First line: A string
s1
(1 ≤ length ≤ 1000). - Second line: A string
s2
(1 ≤ length ≤ 1000).
Output Format: An integer representing the length of the longest common subsequence.
Constraints: - 1 ≤ length of
s1
,s2
≤ 1000 - Strings contain only lowercase letters (a-z).
Example:Input: ABCDGH AEDFHR Output: 3
Explanation: The longest common subsequence is "ADH" with length 3.
- First line: A string
- Check for Balanced Parentheses
Description: Given a string containing only parentheses (i.e., ‘(’, ‘)’), determine if the string is balanced, meaning every opening parenthesis has a corresponding closing parenthesis in the correct order.
Input Format:- A single line containing a string
s
of parentheses (1 ≤ length ≤ 10^5).
Output Format: A string, "Yes" if the parentheses are balanced, "No" otherwise.
Constraints: - 1 ≤ length of
s
≤ 10^5 s
contains only ‘(’ and ‘)’.
Example:Input: (()) Output: Yes
Explanation: The string “(())” is balanced as every opening parenthesis has a matching closing parenthesis.
- A single line containing a string
- Find Missing Number in Array
Description: Given an array ofn-1
distinct integers in the range[1, n]
, find the missing number in the sequence.
Input Format:- First line: An integer
n
, the range of numbers (2 ≤ n ≤ 10^5). - Second line:
n-1
integers representing the array elements (1 ≤ elements ≤ n).
Output Format: An integer representing the missing number.
Constraints: - 2 ≤ n ≤ 10^5
- 1 ≤ elements ≤ n, all distinct.
Example:Input: 5 1 2 4 5 Output: 3
Explanation: The numbers are in the range [1, 5], and 3 is missing from the array [1, 2, 4, 5].
- First line: An integer
- Kth Largest Element in an Array
Description: Given an array of integers, find the kth largest element in the array. The elements are not necessarily distinct.
Input Format:- First line: Two integers
n
(array size) andk
(1 ≤ k ≤ n ≤ 10^5). - Second line:
n
integers representing the array elements (1 ≤ elements ≤ 10^6).
Output Format: An integer representing the kth largest element.
Constraints: - 1 ≤ k ≤ n ≤ 10^5
- 1 ≤ elements ≤ 10^6
Example:Input: 5 2 3 1 4 5 2 Output: 4
Explanation: The sorted array in descending order is [5, 4, 3, 2, 1], so the 2nd largest element is 4.
- First line: Two integers
- Matrix Spiral Traversal
Description: Given a 2D matrix of sizem x n
, print its elements in a spiral order, starting from the top-left corner and moving clockwise.
Input Format:- First line: Two integers
m
(rows) andn
(columns) (1 ≤ m, n ≤ 100). - Next
m
lines:n
integers each, representing the matrix elements (1 ≤ elements ≤ 10^4).
Output Format: A single line containing the matrix elements in spiral order, separated by spaces.
Constraints: - 1 ≤ m, n ≤ 100
- 1 ≤ elements ≤ 10^4
Example:Input: 3 3 1 2 3 4 5 6 7 8 9 Output: 1 2 3 6 9 8 7 4 5
Explanation: The elements are printed in a clockwise spiral starting from (0,0): 1, 2, 3, 6, 9, 8, 7, 4, 5.
- First line: Two integers
Note: Oracle’s coding questions vary by year, role (e.g., Software Engineer, Applications Engineer), and platform (e.g., CodeStreet, HackerRank). The above problems reflect common patterns and difficulty levels seen in Oracle’s recruitment drives. If you need problems specific to a particular year, role, or platform, please provide additional details, and I can search for or tailor more relevant problem statements.
Most Asked Oracle Coding Questions
Array & String Problems
- Two Sum : Find two numbers in array that add up to target sum
- Maximum Subarray (Kadane's) : Find contiguous subarray with maximum sum
- Stock Buy Sell : Calculate maximum profit from buying and selling stocks
- Rotate Array : Rotate array to right by k steps
- Remove Duplicates : Remove duplicates from sorted array in-place
- Merge Sorted Arrays : Merge two sorted arrays into one
- Valid Anagram : Check if two strings are anagrams
- Longest Substring Without Repeating : Find longest substring with unique characters
- String Palindrome : Check if string reads same forwards and backwards
- First Missing Positive : Find smallest missing positive integer
Mathematical & Logic Problems
- Fibonacci Series : Generate nth Fibonacci number
- Prime Number Check : Determine if given number is prime
- Factorial Calculation : Calculate factorial of a number
- Power of Two : Check if number is power of 2
- Reverse Integer : Reverse digits of an integer
- Count Digits : Count number of digits in integer
- GCD/LCM : Find greatest common divisor or least common multiple
- Perfect Square : Check if number is perfect square
- Happy Number : Determine if number leads to 1 through digit square sum
- Armstrong Number : Check if number equals sum of cubes of digits
Tree & Graph Problems
- Binary Tree Traversal : Implement inorder, preorder, postorder traversal
- Tree Height : Find maximum depth of binary tree
- Symmetric Tree : Check if binary tree is mirror of itself
- Path Sum : Check if tree has root-to-leaf path with given sum
- Level Order Traversal : Print tree level by level (BFS)
- Lowest Common Ancestor : Find LCA of two nodes in tree
- Binary Search Tree Validation : Check if tree is valid BST
- Graph BFS/DFS : Implement breadth-first and depth-first search
- Connected Components : Count number of connected components in graph
- Shortest Path : Find shortest path between two nodes
Sorting & Searching
- Binary Search : Search element in sorted array
- Merge Sort : Sort array using divide and conquer
- Quick Sort : Sort array using pivot partitioning
- Bubble Sort : Sort using adjacent element swapping
- Selection Sort : Sort by repeatedly finding minimum element
- Search in Rotated Array : Find element in rotated sorted array
- Find Peak Element : Locate peak in array where element is greater than neighbors
- Search 2D Matrix : Search element in row and column sorted matrix
- Kth Largest Element : Find kth largest element in array
- Median of Arrays : Find median of two sorted arrays
Dynamic Programming
- Climbing Stairs: Count ways to reach top taking 1 or 2 steps
- House Robber: Maximum money robber can steal without robbing adjacent houses
- Coin Change: Minimum coins needed to make target amount
- Longest Increasing Subsequence: Find length of longest increasing subsequence
- Edit Distance: Minimum operations to convert one string to another
- Maximum Product Subarray: Find subarray with maximum product
- Unique Paths: Count unique paths in grid from top-left to bottom-right
- Knapsack Problem: Maximum value items that fit in knapsack capacity
- Palindrome Partitioning: Minimum cuts needed to partition string into palindromes
- Word Break: Check if string can be segmented into dictionary words
Stack & Queue Problems
- Valid Parentheses: Check if parentheses are balanced
- Next Greater Element: Find next greater element for each array element
- Min Stack: Design stack with getMin() operation in O(1)
- Queue using Stacks: Implement queue using two stacks
- Stack using Queues: Implement stack using two queues
- Largest Rectangle Histogram: Find largest rectangle area in histogram
- Sliding Window Maximum: Find maximum in each sliding window of size k
- Evaluate Expression: Evaluate mathematical expression with operators
- Simplify Path: Simplify Unix-style file path
- Daily Temperatures: Find how many days until warmer temperature
Linked List Problems
- Reverse Linked List: Reverse singly linked list iteratively/recursively
- Merge Two Lists: Merge two sorted linked lists
- Cycle Detection: Detect if linked list has cycle using Floyd's algorithm
- Remove Nth Node: Remove nth node from end of linked list
- Intersection Point: Find where two linked lists intersect
- Palindrome List: Check if linked list forms palindrome
- Add Two Numbers: Add numbers represented as linked lists
- Copy Random Pointer: Deep copy linked list with random pointers
- Sort List: Sort linked list in O(n log n) time
- Flatten List: Flatten multilevel doubly linked list
Hash Table & Set Problems
- Group Anagrams: Group strings that are anagrams together
- Top K Frequent: Find k most frequent elements in array
- Subarray Sum K: Count subarrays with sum equal to k
- Longest Consecutive: Find longest consecutive sequence length
- Word Pattern: Check if string follows given pattern
- Contains Duplicate: Check if array contains duplicates
- Intersection of Arrays: Find intersection of two arrays
- Valid Sudoku: Check if Sudoku board is valid
- Find Difference: Find character added in second string
- Ransom Note: Check if ransom note can be constructed from magazine
Oracle-Specific Database Problems
- Employee Salary Queries: SQL queries on employee database
- Nth Highest Salary: Find nth highest salary using SQL
- Department Rankings: Rank employees within departments
- Date Manipulations: Handle date calculations and formatting
- Hierarchical Queries: Query parent-child relationships using CONNECT BY
- Window Functions: Use ROW_NUMBER, RANK, DENSE_RANK functions
- Pivot Operations: Transform rows to columns and vice versa
- Regular Expressions: Pattern matching using REGEXP functions
- PL/SQL Procedures: Write stored procedures and functions
- Exception Handling: Handle exceptions in PL/SQL code
Advanced Problems
- LRU Cache: Design Least Recently Used cache
- Trie Implementation: Implement prefix tree data structure
- Serialize/Deserialize: Convert tree to string and back
- Design Twitter: Design social media feed system
- Rate Limiter: Design API rate limiting system
- Consistent Hashing: Distribute keys across servers
- Map Reduce: Process large datasets using map-reduce pattern
- Load Balancer: Distribute requests across multiple servers
- Cache System: Design distributed caching system
- URL Shortener: Design system like bit.ly or tinyurl
Join Telegram group for any doubts & discussions!