* Added surface area of a cuboid
Added surface area of a cuboid according to the formula:
S = 2 * (ab + ac + bc)
* Removed extra white space
* Added test for cuboid surface area
* fixed syntax error
* Removed extra space
* Added tests for cuboid surface area that should fail
I have added tests for cuboid surface area where one of the parameters is invalid. These should fail.
* Added volume of a torus
Added function calculation the volume of a torus according to the formula:
V = 2 * pi^2 * R * r^2
where R is the major radius and r is the minor radius of the torus.
* Added test for torus volume
* Added volume of a pyramid frustum
Added a function calculating volume of a pyramid frustum, V=(S1+S2+sqrt(S1*S2))*h/3
* compiler error fixed
* Added pyramid frustum test case
* extra space removed
* Add Longest Repeated Substring algorithm
Implement LongestRepeatedSubstring in the strings package using the
existing SuffixArray and Kasai's algorithm for LCP array construction.
Includes parameterized unit tests covering typical and edge cases.
* style: reformat test file per clang-format and add coverage test
---------
Co-authored-by: Çağlar Eker <eker.caglar@hepsiburada.com>
* add Subarray Sum Equals K using prefix sum
* Add RangeSumQuery algorithm in prefix folder
* chore: apply clang-format to RangeSumQueryTest file
* Add import statement for JUnit test class
---------
Co-authored-by: Deniz Altunkapan <deniz.altunkapan@outlook.com>
* Add Tower of Hanoi recursive algorithm with tests
* Fix SpotBugs issues and format TowerOfHanoi tests
* Enhance existing TowerOfHanoi and remove duplicate recursion version
* Fix clang-format issue
---------
Co-authored-by: Deniz Altunkapan <deniz.altunkapan@outlook.com>
* fix:shape's dimension constraints added correctyl (issue id: #7260)
* fix: base changed to baseLength for better understanding
* fix: base changed to baseLength for better understanding
* base changed to baseLength for better understanding
* fix:cleared some format issues
* fix:cleared some format issues
### Summary
This PR makes small readability and maintainability improvements to the algorithm implementation.
### Changes
- Removed a redundant `n < 0` validation check since the method contract already ensures valid `n`
- Replaced `current.remove(current.size() - 1)` with `current.removeLast()` to better express backtracking intent
### Rationale
- Simplifies input validation without changing behavior
- Uses the `Deque` API to make the backtracking step clearer and less error-prone
### Impact
- No change in algorithm logic or time/space complexity
- Output remains identical
Co-authored-by: Swati Vusurumarthi <swativs869@gmail.com>
refactor: remove duplicate algorithm implementations
Removed the following duplicate implementations:
- searches/PerfectBinarySearch.java (duplicate of IterativeBinarySearch)
- searches/SortOrderAgnosticBinarySearch.java (duplicate of OrderAgnosticBinarySearch)
- strings/LongestPalindromicSubstring.java (duplicate of dynamicprogramming version)
- strings/ValidParentheses.java (duplicate of stacks version)
- others/cn/HammingDistance.java (duplicate - strings version handles text)
- others/NewManShanksPrimeTest.java (orphan test in wrong package)
Updated DIRECTORY.md to reflect the changes.
Fixes#7253
Co-authored-by: Ahmed Allam <60698204+AllamF5J@users.noreply.github.com>
* docs: Add comprehensive documentation to BinarySearch algorithm
- Added detailed JavaDoc with @param, @return, @throws tags
- Included step-by-step algorithm walkthrough example
- Added inline comments explaining each code section
- Documented time and space complexity analysis
- Provided concrete usage examples with expected outputs
- Explained edge cases and overflow prevention technique
* style: Apply proper Java formatting to BinarySearch
- Fixed line length to meet style guidelines
- Applied proper JavaDoc formatting
- Corrected indentation and spacing
- Ensured compliance with project formatting standards
* fix: correct Javadoc formatting and add missing newline at EOF
- Fix Javadoc structure with proper tag ordering (description before @params)
- Remove incorrect @throws tag (method returns -1, doesn't throw)
- Format algorithm steps as proper HTML ordered list
- Move complexity analysis before @param tags
- Add missing newline at end of file
- Fix example code to use instance method call
* feat: implement Smooth Sort algorithm with detailed JavaDoc and test class
* style: format LEONARDO array for improved readability with clang-format
* feat: add MiddleOfLinkedList class and corresponding test cases
* docs: update documentation for MiddleOfLinkedList class
* test: refactor MiddleOfLinkedListTest to improve readability and assertions
* test: refactor MiddleOfLinkedListTest for improved null safety and readability
---------
Co-authored-by: Ahmed Allam <60698204+AllamF5J@users.noreply.github.com>
* feat: implement Smooth Sort algorithm with detailed JavaDoc and test class
* style: format LEONARDO array for improved readability with clang-format
* feat(sorts): add TournamentSort (winner-tree)
* test: add unit test for null array handling in TournamentSort
* feat(search): add rotated binary search
* test: add unit test for handling middle element in right sorted half of rotated array
---------
Co-authored-by: Ahmed Allam <60698204+AllamF5J@users.noreply.github.com>