Removing old questions

Removed questions uploaded using an old version of LeetHub
Questions 2,3,4,19,36,141,206
This commit is contained in:
devenperez
2023-01-08 09:19:00 -05:00
parent 7b2728ea47
commit 4cc7c8cc70
20 changed files with 0 additions and 498 deletions
@@ -1,47 +0,0 @@
class Solution(object):
def findMedianSortedArrays(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: float
"""
# Variables
totalLength = len(nums1) + len(nums2)
goalIndex = (totalLength / 2.0) - 0.5 # Index of median
num1Index = 0
num2Index = 0
median = 0.0
# Go through arrays simultaniously
# Indexing up only on the lower number
# Stop after we hit "goalIndex"
for i in range(int(goalIndex + 1.5)):
# OOB Checks
if num1Index >= len(nums1):
lowestNum2 = nums2[num2Index]
lowestNum1 = lowestNum2 + 1
elif num2Index >= len(nums2):
lowestNum1 = nums1[num1Index]
lowestNum2 = lowestNum1 + 1
else:
# QOL variables
lowestNum1 = nums1[num1Index]
lowestNum2 = nums2[num2Index]
# Index up logic
if lowestNum1 <= lowestNum2:
num1Index += 1
if i == int(goalIndex) or i == round(goalIndex):
median += lowestNum1
else:
num2Index += 1
if i == int(goalIndex) or i == round(goalIndex):
median += lowestNum2
# Divide median by 2 if array is even
if int(goalIndex) != round(goalIndex):
median /= 2
return median
-1
View File
@@ -1 +0,0 @@
-31
View File
@@ -1,31 +0,0 @@
<h2><a href="https://leetcode.com/problems/median-of-two-sorted-arrays/">4. Median of Two Sorted Arrays</a></h2><h3>Hard</h3><hr><div><p>Given two sorted arrays <code>nums1</code> and <code>nums2</code> of size <code>m</code> and <code>n</code> respectively, return <strong>the median</strong> of the two sorted arrays.</p>
<p>The overall run time complexity should be <code>O(log (m+n))</code>.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre><strong>Input:</strong> nums1 = [1,3], nums2 = [2]
<strong>Output:</strong> 2.00000
<strong>Explanation:</strong> merged array = [1,2,3] and median is 2.
</pre>
<p><strong>Example 2:</strong></p>
<pre><strong>Input:</strong> nums1 = [1,2], nums2 = [3,4]
<strong>Output:</strong> 2.50000
<strong>Explanation:</strong> merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>nums1.length == m</code></li>
<li><code>nums2.length == n</code></li>
<li><code>0 &lt;= m &lt;= 1000</code></li>
<li><code>0 &lt;= n &lt;= 1000</code></li>
<li><code>1 &lt;= m + n &lt;= 2000</code></li>
<li><code>-10<sup>6</sup> &lt;= nums1[i], nums2[i] &lt;= 10<sup>6</sup></code></li>
</ul>
</div>