FastPrepValid Parentheses
Problems/Valid Parentheses

Valid Parentheses

Oracle logoOracle● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report identifies this task and its central operation. This practice version states the deterministic interface, boundary behavior, and ordering rules needed for consistent execution while preserving the reported capability.

Given a string s containing only the bracket characters (, ), [, ], {, and }, determine whether it is valid.

A string is valid when every opening bracket is closed by the same type of bracket and brackets close in the reverse order in which they were opened. The empty string is valid.

Return true if s is valid; otherwise, return false.

Function

isValidParentheses(s: String) → boolean

Examples

Example 1

s = "()[]{}"return = true

Each opening bracket is immediately followed by its matching closing bracket.

Example 2

s = "([{}])"return = true

The brackets are properly nested and close in reverse opening order.

Example 3

s = "([)]"return = false

The closing parenthesis appears before the nested square bracket is closed.

Constraints

  • 0 <= s.length <= 100000.
  • Every character of s is one of ()[]{}.

More Oracle problems

  • Maximum Subarray Sum with One DeletionONSITE INTERVIEW · Seen Nov 2026
  • Shortest Deletion for Distinct CharactersONSITE INTERVIEW · Seen Nov 2026
  • Count Dropped Rate-Limited RequestsONSITE INTERVIEW · Seen Nov 2026
All Oracle interview questionsSee Oracle hiring insights
Saved
class Solution {
    public boolean isValidParentheses(String s) {
        // write your code here
    }
}
Checking account…