Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Balanced Parentheses Check
00:00
5 left

Balanced Parentheses Check

EasyPython

Problem

Implement a function that checks for balanced parentheses.

Given a string containing only ( and ), return True if every opening parenthesis is closed in the correct order, and False otherwise. An empty string is considered balanced.

Function: def is_balanced_parentheses(s):

Return a boolean value.

Constraints

  • 0 <= len(s) <= 10^5
  • s contains only ( and ) characters
  • The empty string is considered balanced

Function Signature

def is_balanced_parentheses(s):
Interviewer

Your question is Balanced Parentheses Check. 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.