Skip to content

Commit f75411f

Browse files
authored
Merge pull request #193 from ashmichheda/master
add python solution for Problem 04
2 parents 9531c2a + 509deda commit f75411f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
3+
# concatenate the 2 lists and sort them
4+
nums1 += nums2
5+
nums1.sort()
6+
length = len(nums1)
7+
value = length/2
8+
if length % 2 == 0:
9+
value = int(value)
10+
return (nums1[value-1] + nums1[value])/2
11+
else:
12+
return nums1[int(value)]

Diff for: solution/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
│   ├── Solution.go
3333
│   ├── Solution.java
3434
│   └── Solution.js
35+
│   └── Solution.py
3536
├── 0005.Longest Palindromic Substring
3637
│   ├── README.md
3738
│   ├── Solution.go

0 commit comments

Comments
 (0)