Skip to content

Commit 4071db1

Browse files
authored
Added python solution for the hard problem find median of two sorted arrays (Tahanima#51)
* added python solution to hard problem * Update Solution.py * added python solution to easy problem good triplets * Revert "added python solution to easy problem good triplets" This reverts commit aa4af3b.
1 parent c67a778 commit 4071db1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This solution is for python3, may or may not work for other versions
2+
3+
class Solution:
4+
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
5+
nums3 = nums1 + nums2
6+
nums3.sort()
7+
8+
if len(nums3) % 2 != 0:
9+
return nums3[(len(nums3) // 2)]
10+
else:
11+
return (
12+
nums3[(len(nums3) // 2)-1] +
13+
nums3[(len(nums3) // 2)]
14+
) / 2

0 commit comments

Comments
 (0)