Skip to content

brute-force passed - 3703. Remove K-Balanced Substrings #32675

@EndlessCheng

Description

@EndlessCheng

LeetCode Username

endlesscheng

Problem Number, Title, and Link

  1. Remove K-Balanced Substrings https://leetcode.com/problems/remove-k-balanced-substrings/description/

Bug Category

Missing test case (Incorrect/Inefficient Code getting accepted because of missing test cases)

Bug Description

The following brute-force algorithm passed the worst-case data in 6 seconds.

Language Used for Code

Python/Python3

Code used for Submit/Run operation

class Solution:
    def removeSubstring(self, s: str, k: int) -> str:
        t = '(' * k + ')' * k
        while t in s:
            s = s.replace(t, '')
        return s

Expected behavior

It is suggested to either increase the constraints or reduce the time limit.

Screenshots

Image

Additional context

Generator:

    n = 10 ** 5
    s = '(' * (n // 2) + ')' * (n // 2)
    k = 1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions