Skip to content

Commit 9765f44

Browse files
authored
Update 0004_Median_of_Two_Sorted_Arrays.java
1 parent 0e79b59 commit 9765f44

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Java/0004_Median_of_Two_Sorted_Arrays.java

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public double findMedianSortedArrays(int nums1[], int nums2[]) {
1212
int nums1High = nums1Len;
1313
// find the partition where all left side numbers of nums1 and nums2 are smaller than right side numbers
1414
while (nums1Low <= nums1High) {
15+
// if the total length of two arrays is even, the number of left side numbers == the number of right side numbers
16+
// if the total length of two arrays is odd, the number of left sisde numbers + 1 == the number of right side numbers
1517
int nums1Partition = (nums1Low + nums1High)/2;
1618
int nums2Partition = (nums1Len + nums2Len + 1)/2 - nums1Partition;
1719

0 commit comments

Comments
 (0)