Oracle logo

Oracle Hard Interview Questions

2 hard-level practice questions for Oracle technical 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 Hard Verified Question #1

1. 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
Want to practise this one?
Create a free account to open the full question and practise Oracle questions with AI.
Sign up free
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

Start practicing Oracle questions

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

Get Started Free