-
-
Notifications
You must be signed in to change notification settings - Fork 46.1k
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
Update data_structures/arrays/median_two_array.py #12455
base: master
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
nums1: The first array. | ||
nums2: The second array. | ||
nums1: The first sorted array. | ||
nums2: The second sorted array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this function to fail if either array is not sorted and we need one or more tests that prove it does so.
|
||
if total % 2 == 1: # If the total number of elements is odd | ||
return float(merged[total // 2]) # then return the middle element | ||
# Insert 2: Debugging: Log partition indices and elements (useful for large arrays) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Insert 2: Debugging: Log partition indices and elements (useful for large arrays) | |
# Insert 2: Debugging: Log partition indices and elements (useful for large | |
# arrays) |
low = partition1 + 1 | ||
|
||
# Insert 3: Remove redundant exception, already handled at the beginning | ||
# raise ValueError("Input arrays are not sorted.") # This line is no longer necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as there is a test that proves that failure then we can consider to remove this.
|
||
Returns: | ||
True if the array is sorted, False otherwise. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doctests?
Describe your change:
Checklist: