Skip to content

Conversation

@mike-turintech
Copy link
Member

This pull request refactors and optimizes several methods in the Double class, specifically targeting sumSquare, sumTriangle, countPairs, and countDuplicates. Key changes include:

  1. sumSquare: Replaced nested loops with a direct computation, improving performance from O(n^2) to O(n).
  2. sumTriangle: Utilized the triangular number formula to simplify the logic and reduce complexity.
  3. countPairs: Implemented a counting array to efficiently count pairs, enhancing performance from O(n^2) to O(n).
  4. countDuplicates: Streamlined the method to use a single loop, improving clarity and efficiency.

These enhancements improve both performance and readability, making the methods more suitable for larger datasets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants