Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Valid Parentheses Coding
00:00
5 left

Valid Parentheses Coding

EasyPython

Problem

FloQast Close can represent checklist and workflow expressions using grouped delimiters. Given a string containing only (), [], and {}, determine whether every opening delimiter is closed by the correct type in the correct order.

A string is valid when each opening delimiter has a matching closing delimiter, delimiters are closed in last-in, first-out order, and no closing delimiter appears without a corresponding opening delimiter.

Formal Specification

Implement is_valid_parentheses(s), which accepts a string s and returns a boolean. Return True if the delimiters are valid, otherwise return False.

Constraints

  • 1 <= len(s) <= 10^4
  • s contains only parentheses, square brackets, and curly braces
  • The input may be invalid

Function Signature

def is_valid_parentheses(s):
Interviewer

Your question is Valid Parentheses Coding. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.