Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Problem: Median of Two Sorted Arrays
Platform: LeetCode
Problem Code: 4
Difficulty: Hard
Link: https://leetcode.com/problems/median-of-two-sorted-arrays/description/

Problem Statement:
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

The overall run time complexity should be O(log (m+n)).

Example 1:

Input: nums1 = [1,3], nums2 = [2]
Output: 2.00000
Explanation: merged array = [1,2,3] and median is 2.
Example 2:

Input: nums1 = [1,2], nums2 = [3,4]
Output: 2.50000
Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.

Constraints:

nums1.length == m
nums2.length == n
0 <= m <= 1000
0 <= n <= 1000
1 <= m + n <= 2000
-106 <= nums1[i], nums2[i] <= 106

Approach:
1. Made a vector to store all values
2. Looped through both arrays simultaneously, and pushed elements in ascending order into the vector.
3. If there exists "a" median element, then return it, else return average of the 2 medians.

Time Complexity: O(m+n)
Space Complexity: O(n)

Contributor: SamaKool
*/
class Solution {
public:
double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
int m = nums1.size();
int n = nums2.size();
vector<int> lol;
int j = 0;
int i = 0;
while (i < m && j < n) {
if (nums1[i] < nums2[j]) {
lol.push_back(nums1[i]);
i++;
} else {
lol.push_back(nums2[j]);
j++;
}
}
while (i < m) {
lol.push_back(nums1[i]);
i++;
}
while (j < n) {
lol.push_back(nums2[j]);
j++;
}
if((m+n)%2 != 0){
return lol[((m+n-1)/2)];
}
else{
return (lol[(m+n)/2] + lol[((m+n)/2) - 1]) / 2.0;
}
}
};
15 changes: 11 additions & 4 deletions DomainsLeaderboards/Overall.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ Welcome to the ProjectHive Leaderboard! This page automatically tracks all contr

| Rank | Contributor | Total PRs | Domains Contributed | Last Active |
|------|-------------|-----------|---------------------|-------------|
| 🥇 | [@Tejas-Santosh-Nalawade](https://github.com/Tejas-Santosh-Nalawade) | 20 | 13 (AI-ML, AR-VR, Backend, Blockchain, Cloud, Cybersecurity, DevOps, Frontend, FullStack, IoT, MLOps, NLP, Robotics-Automation) | Recent |
| 🥇 | [@Tejas-Santosh-Nalawade](https://github.com/Tejas-Santosh-Nalawade) | 19 | 13 (AI-ML, AR-VR, Backend, Blockchain, Cloud, Cybersecurity, DevOps, Frontend, FullStack, IoT, MLOps, NLP, Robotics-Automation) | Recent |
| 🥈 | [@Ogagaoghene](https://github.com/Ogagaoghene) | 2 | 1 (Backend) | Recent |
| 🥉 | [@SanjeevDeori](https://github.com/SanjeevDeori) | 1 | 1 (Frontend) | Recent |
| 4 | [@snehal492006](https://github.com/snehal492006) | 1 | 1 (Frontend) | Recent |
| 5 | [@Mansi13-6](https://github.com/Mansi13-6) | 1 | 1 (Frontend) | Recent |
| 🥉 | [@SamaKool](https://github.com/SamaKool) | 1 | 1 (CompetitiveProgramming) | Recent |
| 4 | [@SanjeevDeori](https://github.com/SanjeevDeori) | 1 | 1 (Frontend) | Recent |
| 5 | [@snehal492006](https://github.com/snehal492006) | 1 | 1 (Frontend) | Recent |
| 6 | [@Mansi13-6](https://github.com/Mansi13-6) | 1 | 1 (Frontend) | Recent |

---

## 📊 Domain Breakdown

### CompetitiveProgramming

| Contributor | Contributions |
|-------------|---------------|
| [@SamaKool](https://github.com/SamaKool) | 1 |

### AI-ML

| Contributor | Contributions |
Expand Down
24 changes: 13 additions & 11 deletions HallOfFame/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co

**[@Tejas-Santosh-Nalawade](https://github.com/Tejas-Santosh-Nalawade)**

*Contributions: 20 PRs across 13 domain(s)*
*Contributions: 19 PRs across 13 domain(s)*

*Domains: AI-ML, AR-VR, Backend, Blockchain, Cloud, Cybersecurity, DevOps, Frontend, FullStack, IoT, MLOps, NLP, Robotics-Automation*

Expand Down Expand Up @@ -54,13 +54,13 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co

<div align="center">

<img src="https://github.com/SanjeevDeori.png" width="100" height="100" style="border-radius: 50%;" alt="SanjeevDeori"/>
<img src="https://github.com/SamaKool.png" width="100" height="100" style="border-radius: 50%;" alt="SamaKool"/>

**[@SanjeevDeori](https://github.com/SanjeevDeori)**
**[@SamaKool](https://github.com/SamaKool)**

*Contributions: 1 PRs across 1 domain(s)*

*Domains: Frontend*
*Domains: CompetitiveProgramming*

</div>

Expand All @@ -70,9 +70,9 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co

<div align="center">

<img src="https://github.com/snehal492006.png" width="100" height="100" style="border-radius: 50%;" alt="snehal492006"/>
<img src="https://github.com/SanjeevDeori.png" width="100" height="100" style="border-radius: 50%;" alt="SanjeevDeori"/>

**[@snehal492006](https://github.com/snehal492006)**
**[@SanjeevDeori](https://github.com/SanjeevDeori)**

*Contributions: 1 PRs across 1 domain(s)*

Expand All @@ -86,9 +86,9 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co

<div align="center">

<img src="https://github.com/Mansi13-6.png" width="100" height="100" style="border-radius: 50%;" alt="Mansi13-6"/>
<img src="https://github.com/snehal492006.png" width="100" height="100" style="border-radius: 50%;" alt="snehal492006"/>

**[@Mansi13-6](https://github.com/Mansi13-6)**
**[@snehal492006](https://github.com/snehal492006)**

*Contributions: 1 PRs across 1 domain(s)*

Expand All @@ -102,11 +102,13 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co

<div align="center">

<img src="https://github.com/github.png" width="100" height="100" style="border-radius: 50%;" alt="Pending"/>
<img src="https://github.com/Mansi13-6.png" width="100" height="100" style="border-radius: 50%;" alt="Mansi13-6"/>

**[Username Pending]**
**[@Mansi13-6](https://github.com/Mansi13-6)**

*Contributions: TBD*
*Contributions: 1 PRs across 1 domain(s)*

*Domains: Frontend*

</div>

Expand Down
Loading