Skip to content

Conversation

@JeevanYewale
Copy link

@JeevanYewale JeevanYewale commented Jan 19, 2026

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new algorithms include a corresponding test class that validates their functionality.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.07%. Comparing base (79cdb98) to head (4c84658).

Files with missing lines Patch % Lines
...om/thealgorithms/searches/BinarySearchStrings.java 93.10% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7221      +/-   ##
============================================
+ Coverage     79.05%   79.07%   +0.01%     
- Complexity     6946     6957      +11     
============================================
  Files           779      780       +1     
  Lines         22908    22937      +29     
  Branches       4502     4508       +6     
============================================
+ Hits          18110    18137      +27     
- Misses         4077     4078       +1     
- Partials        721      722       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@singhc7 singhc7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clang-format check is failing, probably just some whitespace or indentation issues. Run clang-format command on your files to auto-fix the style.

Also, left some comments on the implementation.


while (left <= right) {
int mid = left + (right - left) / 2;
int comparison = targetLower.compareTo(array[mid].toLowerCase());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array[mid].toLowerCase() allocates a new String object every single iteration. That's heavy on memory.

You should just use target.compareToIgnoreCase(array[mid]) here instead.

* @param target the string to search for
* @return index of target string if found, -1 otherwise
*/
public static int searchIgnoreCase(String[] array, String target) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here is 100% identical to the search method above.

Please refactor this to use a private helper method that accepts a Comparator. That way you don't duplicate the binary search code twice.

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