Oracle IC3 interview

oracle logo
oracle
September 2, 2026 · 1 reads

Summary

I was asked to construct an N-ary tree from a balanced-parentheses string during an Oracle IC3 interview.

Full Experience

Construct an N-ary Tree from Balanced Parentheses

I recently encountered this interview problem for oracle IC3 interview:

Given a balanced-parentheses string, construct and return the root of an N-ary tree. Each matching () represents a node, and parentheses directly nested inside it represent its children.

Example:

(()()(()))

A stack-based solution can construct the tree in O(n) time:

  • On (, create a node and add it to the current parent’s children.
  • Push the new node onto the stack.
  • On ), pop the completed node.
  • Return the first node as the root.

Interview Questions (1)

1.

Construct an N-ary Tree from Balanced Parentheses

Data Structures & Algorithms

Given a balanced-parentheses string, construct and return the root of an N-ary tree. Each matching () represents a node, and parentheses directly nested inside it represent its children.

Example: (()()(()))

📣 Found this helpful? Please share it with friends who are preparing for interviews!

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!