Oracle Interview Round 1 | Senior Platform Engineer
Anonymous User
371

Interview Questions I Got

1. Maximum of Minimums of Every Window

Given an array A of size n and an integer x:

  • Consider every continuous subarray of length x.
  • Find the minimum element in each window.
  • Return the maximum among all those minimums.

Example:

A = [1, 3, -1, 5, 3, 6]
x = 3

Windows:
[1, 3, -1] → min = -1
[3, -1, 5] → min = -1
[-1, 5, 3] → min = -1
[5, 3, 6] → min = 3

Answer = 3

Core pattern: Sliding Window + Monotonic Deque.

The tricky part is recognizing that we need to maintain the minimum of the current window efficiently rather than recomputing it for every window.


2. SQL — Classify Nodes in a Tree

Given a table:

id   pid
1    NULL
2    1
3    1
4    2

Where:

  • id = node ID
  • pid = parent ID

Classify every node as:

  • Root → has no parent
  • Inner → has at least one child
  • Leaf → has no children

Expected result:

1 → Root
2 → Inner
3 → Leaf
4 → Leaf

The concept itself was straightforward.

The tricky part was writing the SQL correctly — especially determining whether a node appears as someone else's pid and combining that with the NULL parent condition.

A typical approach is to use:

CASE
    WHEN pid IS NULL THEN 'Root'
    WHEN id IN (SELECT pid FROM Tree WHERE pid IS NOT NULL) THEN 'Inner'
    ELSE 'Leaf'
END
Comments (2)