Oracle logo

Oracle Software Engineer Coding Questions

22 practice questions for Oracle Software Engineer interviews

Oracle software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Easy Verified Question #1

1. Top Recurring Substring


Category: Graph coding problem
A search analytics service needs to find which fixed-length pattern occurs most often in a block of text. Given a lowercase string s and a positive...
Input: Graph (nodes and edges)
Output: Computed result
Want to practise this one?
Create a free account to open the full question and practise Oracle questions with AI.
Sign up free
coding Easy Verified Question #2

2. Active Sprint Filter


Category: Graph coding problem
A project tracking system logs team activity throughout the workday. Each log entry has the format "teamId action timestamp", where action is...
Input: Graph (nodes and edges)
Output: Printed output
coding Medium Verified Question #3

3. Evens Before Odds


Category: Array coding problem
You are given an integer array nums. Rearrange nums so that all even numbers appear before all odd numbers. The relative order of even or odd...
Input: Array
Output: Integer
coding Easy Verified Question #4

4. Top Frequency Substring


Category: Graph coding problem
Given a string text containing only lowercase English letters and a positive integer k, find the substring of length k that appears most...
Input: Graph (nodes and edges)
Output: Computed result
coding Easy Verified Question #5

5. Card Straight Check


Category: String coding problem
You are dealt five playing cards. Determine whether they can form a straight, which is a sequence of five consecutive values regardless of suit. Card...
Input: String
Output: Computed result
coding Medium Verified Question #6

6. Cyclic Digit Primality


Category: Algorithm coding problem
A number is called a cyclic prime if every rotation of its decimal digits produces a prime number. A rotation moves the leftmost digit to the...
Input: Integer(s)
Output: Computed result
coding Medium Verified Question #7

7. Tower Game Optimizer


Category: Array coding problem
A tower has n floors numbered from 0 to n - 1. Each floor has an energy cost to traverse and a reward value. You start a ball at one chosen...
Input: Array
Output: Computed result
coding Medium Verified Question #8

8. Social Network Friend Suggester


Category: Array coding problem
Build a friend recommendation system for a social network. Given n users (indexed 0 to n - 1) and a list of existing friendships (undirected...
Input: Array
Output: Array
coding Medium Verified Question #9

9. Item Price Tracker


Category: Algorithm coding problem
Design a class that tracks the price history of a single product. Price records are keyed by timestamp and can be updated at any time. The tracker...
Input: Given input
Output: Computed result
coding Easy Verified Question #10

10. [CodeSignal] Filtered Palindrome Check


Category: Array coding problem
Given two character arrays skipChars and inputChars, determine whether inputChars forms a palindrome after removing all characters that appear...
Input: Array
Output: Printed output
coding Easy Verified Question #11

11. Eliminate Adjacent Repeats


Category: String coding problem
You are given a string s of lowercase English letters. In one operation, you may change any single character to any other lowercase letter. Find...
Input: String
Output: Integer
coding Easy Verified Question #12

12. [CodeSignal] Adjacent Character Removal


Category: Algorithm coding problem
You have a word of length L made up only of lowercase English letters. A character at position i is called a conflict if it equals the...
Input: Number(s)
Output: Integer
coding Medium Verified Question #13

13. Top Values After Operations


Category: Array coding problem
You are given an array of non-negative integers nums and two integers k and m. Perform exactly k operations on nums. In each operation: 1....
Input: Array
Output: Computed result
coding Easy Verified Question #14

14. Kth Largest Net Borrower


Category: String coding problem
You are analyzing a peer-to-peer lending platform. Each loan is recorded as a triplet [borrower, lender, amount] where borrower and lender are...
Input: List
Output: Computed result
coding Hard Verified Question #15

15. Expression Simplifier


Category: String coding problem
Given an algebraic expression string containing single lowercase-letter variables, the operators + and -, and parentheses ( and ), simplify...
Input: String
Output: Computed result
coding Hard sliding window #1

1. [AI Enabled Coding] OCI Rolling Error Leaderboard


Scenario
An OCI operations team consumes HTTP telemetry from microservices deployed in different OCI compartments. Build an in-memory analyzer that identifies the services generating the most server errors, so operators can distinguish a service-local incident from a compartment-wide incident. This is an interview adaptation of a reported Oracle rolling top-K error-count question, not a specification of an existing OCI API; you may use an AI assistant while implementing it.
Part 1 — Five-minute service leaderboard
  • Input is a list of maps with string keys and string values. Every record has kind and at; at is an ingestion or query time in integer seconds. Records arrive in nondecreasing at order and are processed in list order when times tie.

  • An event also has eventId, timestamp, compartment, service, and status. Its event timestamp may arrive out of order but never exceeds at. Only HTTP statuses from 500 through 599, inclusive, count as errors.

  • Deduplicate globally by eventId: only its first occurrence has any effect, even if that occurrence is successful or already expired. Later occurrences never replace it.

  • The default rule is named service_5m. At query time t, count errors in the exact interval (t - 300, t], grouped by (compartment, service).

  • Return at most two groups with positive counts. Rank by descending error count, then ascending compartment, then ascending service. Set alert to true exactly when the group's count is at least 3.

  • A query record has only kind and at. Produce one result per query, in input order. Events produce no result. Advance time and expire old errors before processing every record.

  • Function signature: analyze(records: list[dict[str, str]]). The return type is up to the candidate; the examples define its required logical contents using JSON. Output timestamps and counts are integers.


Example 1:
Input:
{
  "records": [
    {"kind":"event","at":"0","eventId":"a","timestamp":"0","compartment":"A","service":"api","status":"500"},
    {"kind":"event","at":"100","eventId":"b","timestamp":"100","compartment":"A","service":"api","status":"503"},
    {"kind":"event","at":"200","eventId":"c","timestamp":"200","compartment":"A","service":"api","status":"502"},
    {"kind":"event","at":"250","eventId":"d","timestamp":"250","compartment":"A","service":"worker","status":"500"},
    {"kind":"event","at":"260","eventId":"e","timestamp":"260","compartment":"A","service":"worker","status":"200"},
    {"kind":"query","at":"299"}
  ]
}

Output:
[
  {"at":299,"leaders":[
    {"entity":{"compartment":"A","service":"api"},"errors":3,"alert":true},
    {"entity":{"compartment":"A","service":"worker"},"errors":1,"alert":false}
  ]}
]

Explanation: The window is (-1, 299]. The API has 1 + 1 + 1 = 3 errors and triggers the threshold; the worker has one error, because its HTTP 200 response contributes zero. Both groups fit the two-group limit.
Part 2 — Configurable incident views
Other OCI operations teams need compartment-wide views and different observation windows. Extend the function to analyze(records: list[dict[str, str]], rules: list[dict[str, str]] | None = None) without removing the default rule or changing event handling. Discuss how the return type changes before implementing this extension, and make the approach flexible enough to support future rules of the same kind.
  • Every additional rule is a string-valued map containing name, scope, windowSeconds, alertThreshold, and limit. Names are unique and cannot equal service_5m.

  • scope is either service, grouping by (compartment, service), or compartment, grouping all services by compartment. Each rule counts the same deduplicated HTTP 5xx errors, but uses its own interval (t - windowSeconds, t].

  • Each rule returns up to limit positive-count groups, ordered by descending count and then ascending entity fields: compartment followed by service when present. alert is true exactly when the count is at least alertThreshold; non-alerting groups are still eligible for the leaderboard. Rules do not suppress or modify one another.

  • With rules=None, retain the Part 1 output. With a supplied list, including an empty list, return an evaluations list per query: default rule first, followed by additional rules in ascending name order. Each evaluation contains rule and leaders.

  • Do not rescan historical events or sort every active group at every query. Target total time O((N × R + L) log(N + 1)), where N is the number of records, R includes the default rule, and L is the total number of returned leader entries.


Example 2:
Input:
{
  "rules":[
    {"name":"compartment_2m","scope":"compartment","windowSeconds":"120","alertThreshold":"2","limit":"2"}
  ],
  "records":[
    {"kind":"event","at":"0","eventId":"a","timestamp":"0","compartment":"A","service":"api","status":"500"},
    {"kind":"event","at":"100","eventId":"b","timestamp":"100","compartment":"A","service":"api","status":"500"},
    {"kind":"event","at":"120","eventId":"c","timestamp":"110","compartment":"A","service":"worker","status":"503"},
    {"kind":"event","at":"130","eventId":"d","timestamp":"125","compartment":"B","service":"api","status":"502"},
    {"kind":"query","at":"130"},
    {"kind":"query","at":"300"}
  ]
}

Output:
[
  {"at":130,"evaluations":[
    {"rule":"service_5m","leaders":[
      {"entity":{"compartment":"A","service":"api"},"errors":2,"alert":false},
      {"entity":{"compartment":"A","service":"worker"},"errors":1,"alert":false}
    ]},
    {"rule":"compartment_2m","leaders":[
      {"entity":{"compartment":"A"},"errors":2,"alert":true},
      {"entity":{"compartment":"B"},"errors":1,"alert":false}
    ]}
  ]},
  {"at":300,"evaluations":[
    {"rule":"service_5m","leaders":[
      {"entity":{"compartment":"A","service":"api"},"errors":1,"alert":false},
      {"entity":{"compartment":"A","service":"worker"},"errors":1,"alert":false}
    ]},
    {"rule":"compartment_2m","leaders":[]}
  ]}
]

Explanation: At 130, the default window includes all four errors: A/api has 2, A/worker has 1, and B/api has 1. The two-group limit excludes B/api because A/worker wins the lexical tie. The compartment window is (10, 130], so timestamp 0 is excluded: A has 1 + 1 = 2 and alerts, while B has 1. At 300, the default window is (0, 300], so timestamp 0 expires; all three remaining service groups have count 1, and the lexical tie-break again selects the two A groups. No errors fall in the compartment window (180, 300].
Example 3:
Input:
{
  "rules":[
    {"name":"compartment_2m","scope":"compartment","windowSeconds":"120","alertThreshold":"2","limit":"2"}
  ],
  "records":[
    {"kind":"event","at":"200","eventId":"a","timestamp":"200","compartment":"A","service":"api","status":"500"},
    {"kind":"event","at":"210","eventId":"b","timestamp":"210","compartment":"A","service":"api","status":"503"},
    {"kind":"event","at":"220","eventId":"c","timestamp":"220","compartment":"A","service":"api","status":"502"},
    {"kind":"event","at":"225","eventId":"b","timestamp":"210","compartment":"A","service":"api","status":"503"},
    {"kind":"query","at":"230"},
    {"kind":"event","at":"500","eventId":"late","timestamp":"200","compartment":"A","service":"worker","status":"500"},
    {"kind":"query","at":"500"}
  ]
}

Output:
[
  {"at":230,"evaluations":[
    {"rule":"service_5m","leaders":[
      {"entity":{"compartment":"A","service":"api"},"errors":3,"alert":true}
    ]},
    {"rule":"compartment_2m","leaders":[
      {"entity":{"compartment":"A"},"errors":3,"alert":true}
    ]}
  ]},
  {"at":500,"evaluations":[
    {"rule":"service_5m","leaders":[
      {"entity":{"compartment":"A","service":"api"},"errors":2,"alert":false}
    ]},
    {"rule":"compartment_2m","leaders":[]}
  ]}
]

Explanation: At 230, three unique errors contribute 3 to both views; the duplicate contributes zero. Both rules alert independently because 3 >= 3 and 3 >= 2. At 500, the default window is (200, 500]: the original timestamp-200 error expires, and the newly arriving timestamp-200 error is already outside the window. Only timestamps 210 and 220 remain, totaling 2; neither is in the compartment window (380, 500].
Notes:
  • Assume valid input: at most 200,000 records, at most 8 total rules, windows in [1, 86400], positive alert thresholds, and limits in [1, 100].

  • Times are nonnegative integers. Identifiers are nonempty ASCII strings; lexical comparisons are case-sensitive. HTTP statuses are integers from 100 through 599 represented as strings.

  • Processing is single-threaded. Deduplication lasts for the entire invocation; late events never revise previously returned results.
Want to practise this one?
Create a free account to open the full question and practise Oracle questions with AI.
Sign up free
coding Medium graph #2

2. [Graph] — Find the longest path in a directed graph


Background: Oracle often works with complex data structures and relies on graph representations in systems like Oracle Graph. Finding the longest path in a directed graph can be crucial for optimization tasks in database querying and data analysis.
Problem statement: Given a directed graph represented as an adjacency list, write a function to determine the length of the longest path from a starting vertex to any other vertex. The graph may contain cycles, and you need to ensure the path does not revisit any vertices.
Function/class signature:
  • def longest_path(graph: List[List[int]], start: int) -> int:


Example 1:
Input: graph = [[1, 2], [3], [3], []], start = 0
Output: 3
Explanation: The longest path starts from vertex 0 to 1 to 3, resulting in a path length of 3.
Example 2:
Input: graph = [[1], [2], [3], [1]], start = 0
Output: 3
Explanation: Although there is a cycle involving vertex 1, the longest acyclic path is still from 0 to 1 to 2 to 3, resulting in a path length of 3.
Constraints:
  • 1 <= len(graph) <= 1000

  • 0 <= start < len(graph)

  • Each sublist has at most 10 elements

  • Graph may contain cycles
coding Medium graph #3

3. GRAPH — Find the shortest path in a network of database nodes

Background: Oracle manages vast amounts of data across distributed systems. Efficient routing of queries through networked databases is critical. This problem simulates such a routing challenge.
Problem statement: Given a directed graph representing the database nodes and the connections (edges) between them, write a function to find the shortest path from a source node to a destination node. If no path exists, return None.
Function/class signature:
  • def shortest_path(graph: Dict[str, List[str]], source: str, destination: str) -> List[str]:

Example 1:
  • Input: graph = {'A': ['B', 'C'], 'B': ['D'], 'C': ['D'], 'D': []}, source = 'A', destination = 'D'

  • Output: ['A', 'B', 'D']

  • Explanation: The shortest path from A to D can be achieved through B.

Example 2:
  • Input: graph = {'A': ['B'], 'B': ['C'], 'C': []}, source = 'A', destination = 'D'

  • Output: None

  • Explanation: There is no path from A to D.

Constraints:
  • The graph can have a maximum of 1000 nodes.

  • Each node's adjacency list can have up to 100 connections.

coding Medium tree #4

4. [Tree] — Serialize and Deserialize a Binary Tree

Background: In Oracle's data handling and analytics platforms, it is essential to efficiently store and retrieve tree structures representing hierarchical data. Serializing data structures ensures easy storage and quick innovation in applications.
Problem statement: Implement a class BinaryTreeCodec with methods to serialize and deserialize a binary tree. The serialized output should be a string that maintains the structure of the tree. For a given binary tree, the serialize(root) method should produce a string, and the deserialize(data) method should reconstruct the binary tree from that string.
Function/class signature:
  • def serialize(self, root: TreeNode) -> str:

  • def deserialize(self, data: str) -> TreeNode:


Example 1:
Input: root = [1,2,3,null,null,4,5]
Output: '1,2,3,null,null,4,5'
Explanation: The tree structure can be represented in this list format, and the serialized string maintains the tree hierarchy.
Example 2:
Input: data = '1,2,3,null,null,4,5'
Output: TreeNode(1) with children TreeNode(2), TreeNode(3)
Explanation: The deserialized tree is reconstructed into the original binary tree structure.
Constraints:
  • The binary tree can have up to 1000 nodes.

  • Values of nodes are integers between -10^4 and 10^4.

  • The methods must handle edge cases, including empty trees.
coding Medium graph #5

5. [Graph] — Finding Shortest Path in an Airline Network

Background: Oracle's cloud infrastructure often deals with vast and complex interconnected systems, such as airline flight networks. Efficient pathfinding algorithms are critical to optimize routing and minimize travel time.
Problem statement: Given a set of airports (represented as nodes) and flights (represented as edges with associated costs), implement a function to find the shortest path from a starting airport to a destination airport. Each airport is represented by a string, and the flights are represented by a list of tuples where each tuple contains the departing airport, the arriving airport, and the travel cost.
Function/class signature:
  • def find_shortest_path(flights: List[Tuple[str, str, int]], start: str, destination: str) -> Tuple[List[str], int]:

Example 1:
Input:
flights = [('JFK', 'LAX', 300), ('JFK', 'SFO', 400), ('LAX', 'SFO', 100)]
start = 'JFK'
destination = 'SFO'

Output:
(['JFK', 'LAX', 'SFO'], 400)

Explanation: The shortest path is JFK → LAX → SFO with a total cost of 400.
Example 2:
Input:
flights = [('JFK', 'MIA', 200), ('MIA', 'SFO', 300), ('JFK', 'SFO', 600)]
start = 'JFK'
destination = 'SFO'

Output:
(['JFK', 'MIA', 'SFO'], 500)

Explanation: The optimal route is through MIA costing a total of 500, which is cheaper than the direct route.
Constraints:
  • 1 <= len(flights) <= 1000

  • Cost of flights is positive.

  • All airport names are unique strings.

coding Medium tree #6

6. Binary Tree Inversion — invert a binary tree


Background: Inverting a binary tree is a common operation needed in various algorithms and applications, including graphical representation and data structure manipulation. At Oracle, where efficiency and data management are crucial, mastering binary trees is essential for optimizing database queries and storage systems.
Problem statement: Given the root node of a binary tree, your task is to invert the tree, meaning you need to swap the left and right child nodes at each level. The transformation should be done in place, meaning no additional data structures should be used besides the input tree itself.
Function/class signature:
  • def invert_tree(root: TreeNode) -> TreeNode:


Example 1:
  • Input: root = [4, 2, 7, 1, 3, 6, 9]

  • Output: [4, 7, 2, 9, 6, 3, 1]

  • Explanation: The tree structure after inversion is 4, where the left child 2 becomes the right child 7, and all further inversions follow.


Example 2:
  • Input: root = [2, 1, 3]

  • Output: [2, 3, 1]


Constraints:
  • The tree node count will be between 0 and 1000.

  • Node values will be integers between -100 and 100.
coding Medium two pointers #7

7. Two Pointers — Merge Two Sorted Arrays

2. Background: Oracle often processes large datasets where merging arrays efficiently is crucial for analytics and reporting tools. This problem simulates a common scenario encountered in database management systems.
3. Problem statement: Given two sorted arrays arr1 and arr2, merge them into a single sorted array. The merged array should also be sorted and must not require additional space for an output of size m + n, where m and n are the sizes of arr1 and arr2, respectively. You must return the merged array as your result.
4. Function/class signature:
- def merge_sorted_arrays(arr1: List[int], arr2: List[int]) -> List[int]:
5. Example 1:
- Input: arr1 = [1, 3, 5], arr2 = [2, 4, 6]
- Output: [1, 2, 3, 4, 5, 6]
- Explanation: The merged array maintains the order of the two input arrays.
6. Example 2:
- Input: arr1 = [0, 1, 2], arr2 = [3, 4, 5]
- Output: [0, 1, 2, 3, 4, 5]
7. Constraints:
- 0 <= arr1.length, arr2.length <= 100
- -1000 <= arr1[i], arr2[i] <= 1000

Related Oracle Software Engineer interview prep

Start practicing Oracle questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free