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
2024-10-08 23:59:29 +05:30
2024-09-22 01:54:47 +05:30
2024-01-08 23:48:11 +02:00
2021-02-25 16:15:52 -06:00
2023-06-14 15:37:14 +03:00
2024-04-08 18:08:35 +00:00

The Algorithms - Java

Build codecov Discord chat Gitpod ready-to-code

You can run and edit the algorithms, or contribute to them using Gitpod.io (a free online development environment) with a single click.

Open in Gitpod

All algorithms are implemented in Java (for educational purposes)

These implementations are intended for learning purposes. As such, they may be less efficient than the Java standard library.

Contribution Guidelines

Please read our Contribution Guidelines before you contribute to this project.

Algorithms

Our directory has the full list of applications.

Languages
Java 100%