Skip to content

Added Extreme Case handler & New Test Case in "CalculateMaxOfMin" #5050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

SarthakChaudhary46
Copy link
Contributor

  • 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

@SarthakChaudhary46
Copy link
Contributor Author

Guys, I've been thinking about the current implementation of the algorithm, and I believe it's a bit wrong and there's a more efficient approach we could take. Let me walk you through it:

  • Iterate Through Each Element: We'll start by going through each element in the array.
  • Find the Minimum Subarray: For each element, we'll find the minimum value of the subarray starting from that element and ending at each subsequent element. This way, we're essentially exploring all possible subarrays.
  • Keep Track of the Maximum Minimum Value: As we traverse the array, we'll keep track of the maximum of these minimum values encountered.
  • Return the Maximum Minimum Value Found: Once we've covered the entire array, we'll return the maximum minimum value found.

For example:

Given an array Arr = {10, 20, 30, 50, 10, 70, 30}, the output should be 30.

If you all agree with this approach, I'd love to work on implementing it! Let me know your thoughts.

@vil02
Copy link
Member

vil02 commented Feb 28, 2024

The current implementation of CalculateMaxOfMin is incorrect. Please have a look at the discussion in #5038. As suggested there: this class should be removed and a new implementation should be added. Would you like to do that?

@SarthakChaudhary46
Copy link
Contributor Author

@vil02 Sure, I'll just open a new pr after making the necessary changes.

@vil02
Copy link
Member

vil02 commented Mar 1, 2024

@SarthakChaudhary46 can this PR be closed? If yes, please close it.

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.

2 participants