We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9531c2a + 509deda commit f75411fCopy full SHA for f75411f
solution/0004.Median of Two Sorted Arrays/Solution.py
@@ -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)]
solution/README.md
@@ -32,6 +32,7 @@
32
│ ├── Solution.go
33
│ ├── Solution.java
34
│ └── Solution.js
35
+│ └── Solution.py
36
├── 0005.Longest Palindromic Substring
37
│ ├── README.md
38
0 commit comments