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.

  1. 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.

  1. 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 integer period (years) and a double rate (interest rate in %).
    • Next line: An integer N2, the number of slabs for Bank B (1 ≤ N2 ≤ T).
    • Next N2 lines: Two values, an integer period (years) and a double rate (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.

  1. Borrow Operations for Subtraction
    Description: Given two numbers represented as strings, determine the number of borrow operations required to subtract number2 from number1 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 and number2 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).

  1. 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 and r, 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).

  1. 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.

  1. Network Stream (Largest Repackaged Packet)
    Description: A server receives a stream of n 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.

  1. Distinct Numbers in Multiple Ranges
    Description: Given an array of n integers and m queries, for each query li, find the number of distinct numbers in the subarray from index li to the end of the array (1-based indexing).
    Input Format:
    • First line: Two integers n (array size) and m (number of queries) (1 ≤ n, m ≤ 10^5).
    • Second line: n integers representing the array elements (1 ≤ elements ≤ 10^6).
    • Next m lines: An integer li, 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 from li to n.
      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 query li, count distinct elements from index li to the end. For li = 1, the subarray is [1, 2, 3, 4, 1, 2, 3, 4, 100000, 99999], with 6 distinct values.

  1. 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) and D (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.

  1. Merge Two Sorted Arrays
    Description: Given two sorted arrays of sizes m and n, 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 and n, 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.

  1. 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.

  1. 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.

  1. 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.

  1. Find Missing Number in Array
    Description: Given an array of n-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].

  1. 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) and k (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.

  1. Matrix Spiral Traversal
    Description: Given a 2D matrix of size m 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) and n (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.

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

  1. Two Sum : Find two numbers in array that add up to target sum
  2. Maximum Subarray (Kadane's) : Find contiguous subarray with maximum sum
  3. Stock Buy Sell : Calculate maximum profit from buying and selling stocks
  4. Rotate Array : Rotate array to right by k steps
  5. Remove Duplicates : Remove duplicates from sorted array in-place
  6. Merge Sorted Arrays : Merge two sorted arrays into one
  7. Valid Anagram : Check if two strings are anagrams
  8. Longest Substring Without Repeating : Find longest substring with unique characters
  9. String Palindrome : Check if string reads same forwards and backwards
  10. First Missing Positive : Find smallest missing positive integer

Mathematical & Logic Problems

  1. Fibonacci Series : Generate nth Fibonacci number
  2. Prime Number Check : Determine if given number is prime
  3. Factorial Calculation : Calculate factorial of a number
  4. Power of Two : Check if number is power of 2
  5. Reverse Integer : Reverse digits of an integer
  6. Count Digits : Count number of digits in integer
  7. GCD/LCM : Find greatest common divisor or least common multiple
  8. Perfect Square : Check if number is perfect square
  9. Happy Number : Determine if number leads to 1 through digit square sum
  10. Armstrong Number : Check if number equals sum of cubes of digits

Tree & Graph Problems

  1. Binary Tree Traversal : Implement inorder, preorder, postorder traversal
  2. Tree Height : Find maximum depth of binary tree
  3. Symmetric Tree : Check if binary tree is mirror of itself
  4. Path Sum : Check if tree has root-to-leaf path with given sum
  5. Level Order Traversal : Print tree level by level (BFS)
  6. Lowest Common Ancestor : Find LCA of two nodes in tree
  7. Binary Search Tree Validation : Check if tree is valid BST
  8. Graph BFS/DFS : Implement breadth-first and depth-first search
  9. Connected Components : Count number of connected components in graph
  10. Shortest Path : Find shortest path between two nodes

Sorting & Searching

  1. Binary Search : Search element in sorted array
  2. Merge Sort : Sort array using divide and conquer
  3. Quick Sort : Sort array using pivot partitioning
  4. Bubble Sort : Sort using adjacent element swapping
  5. Selection Sort : Sort by repeatedly finding minimum element
  6. Search in Rotated Array : Find element in rotated sorted array
  7. Find Peak Element : Locate peak in array where element is greater than neighbors
  8. Search 2D Matrix : Search element in row and column sorted matrix
  9. Kth Largest Element : Find kth largest element in array
  10. Median of Arrays : Find median of two sorted arrays

Dynamic Programming

  1. Climbing Stairs: Count ways to reach top taking 1 or 2 steps
  2. House Robber: Maximum money robber can steal without robbing adjacent houses
  3. Coin Change: Minimum coins needed to make target amount
  4. Longest Increasing Subsequence: Find length of longest increasing subsequence
  5. Edit Distance: Minimum operations to convert one string to another
  6. Maximum Product Subarray: Find subarray with maximum product
  7. Unique Paths: Count unique paths in grid from top-left to bottom-right
  8. Knapsack Problem: Maximum value items that fit in knapsack capacity
  9. Palindrome Partitioning: Minimum cuts needed to partition string into palindromes
  10. Word Break: Check if string can be segmented into dictionary words

Stack & Queue Problems

  1. Valid Parentheses: Check if parentheses are balanced
  2. Next Greater Element: Find next greater element for each array element
  3. Min Stack: Design stack with getMin() operation in O(1)
  4. Queue using Stacks: Implement queue using two stacks
  5. Stack using Queues: Implement stack using two queues
  6. Largest Rectangle Histogram: Find largest rectangle area in histogram
  7. Sliding Window Maximum: Find maximum in each sliding window of size k
  8. Evaluate Expression: Evaluate mathematical expression with operators
  9. Simplify Path: Simplify Unix-style file path
  10. Daily Temperatures: Find how many days until warmer temperature

Linked List Problems

  1. Reverse Linked List: Reverse singly linked list iteratively/recursively
  2. Merge Two Lists: Merge two sorted linked lists
  3. Cycle Detection: Detect if linked list has cycle using Floyd's algorithm
  4. Remove Nth Node: Remove nth node from end of linked list
  5. Intersection Point: Find where two linked lists intersect
  6. Palindrome List: Check if linked list forms palindrome
  7. Add Two Numbers: Add numbers represented as linked lists
  8. Copy Random Pointer: Deep copy linked list with random pointers
  9. Sort List: Sort linked list in O(n log n) time
  10. Flatten List: Flatten multilevel doubly linked list

Hash Table & Set Problems

  1. Group Anagrams: Group strings that are anagrams together
  2. Top K Frequent: Find k most frequent elements in array
  3. Subarray Sum K: Count subarrays with sum equal to k
  4. Longest Consecutive: Find longest consecutive sequence length
  5. Word Pattern: Check if string follows given pattern
  6. Contains Duplicate: Check if array contains duplicates
  7. Intersection of Arrays: Find intersection of two arrays
  8. Valid Sudoku: Check if Sudoku board is valid
  9. Find Difference: Find character added in second string
  10. Ransom Note: Check if ransom note can be constructed from magazine

Oracle-Specific Database Problems

  1. Employee Salary Queries: SQL queries on employee database
  2. Nth Highest Salary: Find nth highest salary using SQL
  3. Department Rankings: Rank employees within departments
  4. Date Manipulations: Handle date calculations and formatting
  5. Hierarchical Queries: Query parent-child relationships using CONNECT BY
  6. Window Functions: Use ROW_NUMBER, RANK, DENSE_RANK functions
  7. Pivot Operations: Transform rows to columns and vice versa
  8. Regular Expressions: Pattern matching using REGEXP functions
  9. PL/SQL Procedures: Write stored procedures and functions
  10. Exception Handling: Handle exceptions in PL/SQL code

Advanced Problems

  1. LRU Cache: Design Least Recently Used cache
  2. Trie Implementation: Implement prefix tree data structure
  3. Serialize/Deserialize: Convert tree to string and back
  4. Design Twitter: Design social media feed system
  5. Rate Limiter: Design API rate limiting system
  6. Consistent Hashing: Distribute keys across servers
  7. Map Reduce: Process large datasets using map-reduce pattern
  8. Load Balancer: Distribute requests across multiple servers
  9. Cache System: Design distributed caching system
  10. URL Shortener: Design system like bit.ly or tinyurl

Join Telegram group for any doubts & discussions!

🧰 Useful Resources for Your Placement Prep