Skip to content

Refactor memoized knapsack implementation to remove global state #14464

@anikchand461

Description

@anikchand461

Feature description

The current memoized knapsack implementation relies on a global DP table, which reduces code clarity and reusability. This PR proposes a cleaner implementation using Python’s functools.lru_cache to eliminate global state and improve readability. The updated version will follow repository standards, include type hints, and provide doctests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis PR modified some existing files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions