Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Incorrect initialization for minimum-window-with-characters #5162

@deepwithin

Description

@deepwithin

Bug Report for https://neetcode.io/problems/minimum-window-with-characters

Language: Python

In the sliding window solution, the line

have, need = 0, len(countT)

has incorrect initialization. It should not be length of countT as it is since t might have duplicates. This fails for test case:

s = "aa"
t = "aa"

Correction is:

have, need = 0, len(countT.keys())
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions