FastPrepValid Parenthesis String
Problems/Valid Parenthesis String

Valid Parenthesis String

Motive logoMotive● MediumFULLTIMEINTERNPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Several firsthand Motive reports for full-time and intern onsite interviews describe or link the Valid Parenthesis String problem.

Our version is about 99% the same as the reported questions.

Given a string s containing '(', ')', and '*', return whether it can become a valid parenthesis string.

Each '*' may independently represent an opening parenthesis, a closing parenthesis, or the empty string.

Function

checkValidString(s: String) → boolean

Examples

Example 1

s = "(*)"return = true

The wildcard may be empty.

Example 2

s = "(*))"return = true

Treat the wildcard as an opening parenthesis.

Constraints

  • 0 <= s.length <= 10^5.
  • s contains only (, ), and *.

More Motive Onsite Interview questions

  • Group AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Longest Equal-Zero-One SubarrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Maximum Weighted Sum After Left RotationsONSITE INTERVIEW · Seen Jan 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Dec 2025
  • Target Triplet SumONSITE INTERVIEW · Seen Dec 2025
  • Validate IP AddressONSITE INTERVIEW · Seen Dec 2025
  • Generate Palindromic PermutationsONSITE INTERVIEW · Seen Dec 2025
  • Minimum Swaps to Group Circular OnesONSITE INTERVIEW · Seen Dec 2025
  • Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Dec 2025
  • Search in Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
  • Remove K DigitsProcol · PHONE SCREEN
  • Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Rearrange a String So No Neighbors MatchThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
  • Reorganize a StringAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Longest-Match Tokenizer with Unknown SymbolsAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Minimum Nonadjacent Flips for an Alternating Binary StringInfosys · ONSITE INTERVIEWInfosys interview questions
  • Valid Parenthesis StringOracle · PHONE SCREENOracle interview questions
  • Shortest Way to Form a Target StringPinterest · PHONE SCREENPinterest interview questions
  • Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
All Motive interview questionsSee Motive hiring insights
Saved
class Solution {
    public boolean checkValidString(String s) {
      // write your code here
    }
}
Checking account…