FastPrepValid Parentheses
Problems/Valid Parentheses

Valid Parentheses

Salesforce logoSalesforce● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Salesforce onsite interview. The report names Valid Parentheses and a stack-based solution. It does not give the function signature, examples or limits. Our version is about 92% the same as the reported question.

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

A bracket string is valid when both conditions hold:

  • Every opening bracket is closed by the same type of bracket.
  • Brackets close in the reverse order in which they were opened.

Function

isValidParentheses(s: String) → boolean

Examples

Example 1

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

Each opening bracket is immediately closed by the matching type, so the string is valid.

Example 2

s = "(]"return = false

The opening parenthesis cannot be closed by ].

Example 3

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

The bracket types are properly nested and close from the innermost pair outward.

Constraints

  • 1 <= s.length <= 10^5
  • s contains only ()[]{}.

More Salesforce Onsite Interview questions

  • Count Increasing TripletsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Reverse a Sublist of a Linked ListONSITE INTERVIEW · Seen Nov 2026
  • Rotting OrangesONSITE INTERVIEW · Seen Nov 2026
  • 3Sum SmallerONSITE INTERVIEW · Seen Nov 2026
  • Count Zero Request ServersONSITE INTERVIEW · Seen Nov 2026
  • Group Identical Tree LevelsONSITE INTERVIEW · Seen Oct 2026
  • Meeting Rooms IIONSITE INTERVIEW · Seen Oct 2026
  • Construct a Tree from Level-Order and Inorder TraversalsONSITE INTERVIEW · Seen Sep 2026
  • Maximize Monsters DefeatedONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Valid ParenthesesEPAM · ONSITE INTERVIEWEPAM interview questions
  • Valid ParenthesesQualys · ONSITE INTERVIEWQualys interview questions
  • Rich Text Parser Part 1 (Validate Tokens)Figma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Valid ParenthesesAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Valid ParenthesesKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Minimum Parenthesis Removals and Their IndicesDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Valid ParenthesesBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Maximum Parenthesis Nesting DepthRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Valid ParenthesesZillow · PHONE SCREEN · ONSITE INTERVIEWZillow interview questions

Salesforce interview experiences

  • Salesforce Infrastructure SWE OA and Onsite: 1 Experience
  • Salesforce Experienced Backend SWE First Round: 1 Experience
All Salesforce interview questionsSee Salesforce hiring insights
Saved
class Solution {
    public boolean isValidParentheses(String s) {
        // write your code here
    }
}
Checking account…