From 9a5914f18d22aaa7ec8961b8fa1420d52cbfc005 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:59:18 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- backtracking/generate_parenthesis.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backtracking/generate_parenthesis.py b/backtracking/generate_parenthesis.py index 431355559..4af7f1255 100644 --- a/backtracking/generate_parenthesis.py +++ b/backtracking/generate_parenthesis.py @@ -4,6 +4,7 @@ Problem source: https://leetcode.com/problems/generate-parentheses/ """ + class Solution: def generateParenthesis(self, n): valid = [] @@ -15,12 +16,12 @@ class Solution: return if open_count > 0: - s += '(' + s += "(" generate(s, open_count - 1, close_count) s = s[:-1] if close_count > 0 and open_count < close_count: - s += ')' + s += ")" generate(s, open_count, close_count - 1) s = s[:-1] @@ -28,7 +29,7 @@ class Solution: raise ValueError("Input value must be non-negative") # Start the generation process with an empty string and n opening and closing parentheses - generate('', n, n) + generate("", n, n) """ The function employs backtracking to generate all valid combinations of n pairs of parentheses. It maintains two counters, open_count and close_count, representing available open and close parentheses. @@ -61,4 +62,4 @@ try: # Return the valid combinations print(result) except ValueError: - print("Invalid input. Please enter a non-negative integer.") \ No newline at end of file + print("Invalid input. Please enter a non-negative integer.")