Skip to content

Conversation

anant-jain01
Copy link
Contributor

@anant-jain01 anant-jain01 commented Oct 11, 2024

  • 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 code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Project coverage is 62.88%. Comparing base (2338428) to head (07f5158).

Files with missing lines Patch % Lines
.../main/java/com/thealgorithms/sorts/StalinSort.java 0.00% 13 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5720      +/-   ##
============================================
- Coverage     62.93%   62.88%   -0.06%     
+ Complexity     4044     4043       -1     
============================================
  Files           567      568       +1     
  Lines         16030    16043      +13     
  Branches       3084     3086       +2     
============================================
- Hits          10089    10088       -1     
- Misses         5525     5538      +13     
- Partials        416      417       +1     

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

return trimArray(result, index);
}

private <T> T[] trimArray(T[] array, int length) {
Copy link
Contributor

@saahil-mahato saahil-mahato Oct 11, 2024

Choose a reason for hiding this comment

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

This just adds unnecessary overhead. We can remove this if we use ArrayList.

List<T> result = new ArrayList<>();
result.add(array[0]); 

for (int i = 1; i < array.length; i++) {
    if (SortUtils.less(result.get(result.size() - 1), array[i])) {
        result.add(array[i]);
    }
}


@Override
public <T extends Comparable<T>> T[] sort(T[] array) {
if (array.length == 0) {
Copy link
Contributor

@saahil-mahato saahil-mahato Oct 11, 2024

Choose a reason for hiding this comment

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

add null check here to prevent null pointer exception.

@saahil-mahato
Copy link
Contributor

Please add tests.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Please add JUnit tests

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution!

@github-actions github-actions bot added the stale label Nov 12, 2024
Copy link

Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution!

@github-actions github-actions bot closed this Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants