leetcode icon indicating copy to clipboard operation
leetcode copied to clipboard

Bug Report for validate-parentheses

Open lalog12 opened this issue 1 month ago • 0 comments

Bug Report for https://neetcode.io/problems/validate-parentheses

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible. Description: When writing code in the IDE, indentation inside the for loop does not correctly align with the specified tab size. The editor inserts fewer spaces than expected, leading to incorrect indentation that causes Python code to fail (e.g., premature returns inside loops).

Steps to Reproduce:

Open the problem editor.

Set Font Size: 17px, Tab Size: 4 spaces, Editor Key Bindings: Normal.

Write a function with nested blocks such as a for loop or an if inside a for loop.

Observe that indentation uses fewer spaces than the configured tab size.

Expected Behavior: Indentations inside a for loop should use the configured tab size (4 spaces).

Actual Behavior: The IDE inserts inconsistent indentation (less than 4 spaces), which may cause Python code to execute incorrectly.

Example Code: class Solution: def isValid(self, s: str) -> bool: stack = [] closeToOpen = { "}" : "{" , ")" : "(" , "]" : "[" }

   for c in s:
    # handles opening parenthesis, curly brackets, or brackets
    if c not in closeToOpen:
        stack.append(c)

    else:
        # if c is an opening bracket, we want to input the top of the stack onto the closeToOpen dictionary
        if stack and stack[-1] == closeToOpen[c]:
            stack.pop()
        else:
            return False

    
    return len(stack) == 0

lalog12 avatar Nov 11 '25 20:11 lalog12