Commit Graph

9 Commits

Author SHA1 Message Date
Manish Raj
f3b2a94e74 Improve power sum algorithm (#5652)
* Update directory

* Improve PowerSum algorithm implementation and documentation

This commit enhances the PowerSum class in the backtracking package. The changes focus on improving code quality, readability, and documentation. Key improvements include:

1. Enhanced code structure and efficiency:
   - Removed class-level variables for better thread safety
   - Optimized the recursive approach to avoid unnecessary calculations
   - Simplified the overall logic for easier understanding

2. Improved readability:
   - Used more descriptive variable names (e.g., 'targetSum' instead of 'n', 'power' instead of 'x')
   - Enhanced method structure with a private recursive helper method

3. Better documentation:
   - Added comprehensive JavaDoc comments explaining the algorithm's purpose and implementation
   - Clarified the meaning of parameters, especially relating them to the original problem statement (N and X)
   - Improved inline comments for better code understanding

4. Adhered to Java best practices:
   - Improved encapsulation by making the recursive method private
   - Used Math.pow() directly instead of a custom power method

5. Maintained core functionality:
   - The algorithm still solves the same problem as before, but with improved code quality

* updated PowerSum

* Refactor PowerSum algorithm implementation and documentation

* Refactor PowerSum algorithm implementation and documentation

* Refactor code formatting and remove unnecessary line in PowerSum.java

* Refactor code formatting and add newline at end of file in .clang-format

---------

Co-authored-by: manishraj27 <manishraj27@users.noreply.github.com>
Co-authored-by: Bama Charan Chhandogi <b.c.chhandogi@gmail.com>
2024-10-08 23:59:29 +05:30
Godwill Christopher
c42b1c940c style: enable ParameterName in CheckStyle. (#5196)
* Enabled: ParameterName in CheckStyle.

* Refactored to fix  bug caused by selfAssignment of variables in VectorCrossproduct class
2024-05-31 22:01:11 +02:00
Godwill Christopher
295e7436b1 style: enable MethodName in CheckStyle (#5182)
enabled: MethodName in CheckStyle
2024-05-27 09:06:06 +02:00
vaibhav9t1
9eaa2bb756 style: enable MultipleVariableDeclarations in checkstyle (#5175)
Co-authored-by: vaibhav <vaibhav.waghmare@techprescient.com>
2024-05-25 20:18:27 +02:00
acbin
00282efd8b style: format code (#4212)
close #4204
2023-06-09 18:52:05 +08:00
Om Shinde
64181d6ea7 Remove unnecessary import (#3809) 2023-01-10 09:30:22 +02:00
laks-mi1099
ea05286c86 Add tests for PowerSum (#3603) 2022-10-22 19:11:40 +00:00
acbin
e96f567bfc Format code with prettier (#3375) 2022-10-03 17:23:00 +08:00
Aitor Fidalgo Sánchez
9fb3364ccc Change project structure to a Maven Java project + Refactor (#2816) 2021-11-12 08:59:36 +02:00