Bug Report: Missing Test Case for "Median of Two Sorted Arrays"
Problem Name
Description
The current test suite allows an incorrect solution to pass. The judge accepts logic that only extracts the local median elements from nums1 and nums2, combines/sorts just those elements (a max of 4 numbers), and calculates a median from that subset.
This logic breaks on interleaved arrays where the true global median elements are shifted away from the center positions of the individual arrays.
Missing Test Case
nums1 = [1, 2, 100]
nums2 = [3, 4, 5]
Here is my incorrect version of the code:
class Solution:
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
n = len(nums1)
m = len(nums2)
median = []
if n!= 0:
if n % 2 == 0:
median.append(nums1[int(n/2) - 1])
median.append(nums1[int(n/2)])
else:
median.append(nums1[int((n + 1)/2) - 1])
if m!=0:
if m % 2 == 0:
median.append(nums2[int(m/2) - 1])
median.append(nums2[int(m/2)])
else:
median.append(nums2[int((m + 1)/2) - 1])
median.sort()
print(median)
total = (n + m)
x = len(median)
if (n + m) % 2 != 0:
return median[ int((x + 1) / 2) - 1]
else:
return (int(median [int(x / 2) - 1] + median[int(x/ 2)]))/2
Bug Report: Missing Test Case for "Median of Two Sorted Arrays"
Problem Name
Description
The current test suite allows an incorrect solution to pass. The judge accepts logic that only extracts the local median elements from
nums1andnums2, combines/sorts just those elements (a max of 4 numbers), and calculates a median from that subset.This logic breaks on interleaved arrays where the true global median elements are shifted away from the center positions of the individual arrays.
Missing Test Case