Skip to content

Optimize netBalances function from O(n²) to O(n) using Map for balance lookups #25

@is0692vs

Description

@is0692vs

The netBalances function currently has O(n²) complexity due to nested loops with find() operations. For typical group sizes (~10 users), this is acceptable, but could be optimized to O(n) using a Map for balance lookups.

Consider using a Map to store balances by their userFrom-userTo key for O(1) lookups, reducing overall complexity to O(n).

This was identified in Copilot AI review of PR #24.

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