From 27bb1723ad7c9cfe41591ce5c71c8f75494863b3 Mon Sep 17 00:00:00 2001 From: SamaKool Date: Mon, 20 Oct 2025 00:19:14 +0530 Subject: [PATCH 1/2] Added solution to Median of Two Sorted Arrays --- .../Programs/C++/MedianOfTwoSortedArrays.cpp | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Domains/CompetitiveProgramming/Programs/C++/MedianOfTwoSortedArrays.cpp diff --git a/Domains/CompetitiveProgramming/Programs/C++/MedianOfTwoSortedArrays.cpp b/Domains/CompetitiveProgramming/Programs/C++/MedianOfTwoSortedArrays.cpp new file mode 100644 index 00000000..6c2d9eff --- /dev/null +++ b/Domains/CompetitiveProgramming/Programs/C++/MedianOfTwoSortedArrays.cpp @@ -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& nums1, vector& nums2) { + int m = nums1.size(); + int n = nums2.size(); + vector 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; + } + } +}; \ No newline at end of file From 9a4153c11759047aa41ee09b3e2de24aa0972094 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 19 Oct 2025 18:59:38 +0000 Subject: [PATCH 2/2] chore: Update leaderboard and Hall of Fame after PR #1 --- DomainsLeaderboards/Overall.md | 15 +++++++++++---- HallOfFame/README.md | 24 +++++++++++++----------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/DomainsLeaderboards/Overall.md b/DomainsLeaderboards/Overall.md index 7f4cfc56..176a055a 100644 --- a/DomainsLeaderboards/Overall.md +++ b/DomainsLeaderboards/Overall.md @@ -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 | diff --git a/HallOfFame/README.md b/HallOfFame/README.md index a0bd3260..5ad3bf0a 100644 --- a/HallOfFame/README.md +++ b/HallOfFame/README.md @@ -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* @@ -54,13 +54,13 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co
-SanjeevDeori +SamaKool -**[@SanjeevDeori](https://github.com/SanjeevDeori)** +**[@SamaKool](https://github.com/SamaKool)** *Contributions: 1 PRs across 1 domain(s)* -*Domains: Frontend* +*Domains: CompetitiveProgramming*
@@ -70,9 +70,9 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co
-snehal492006 +SanjeevDeori -**[@snehal492006](https://github.com/snehal492006)** +**[@SanjeevDeori](https://github.com/SanjeevDeori)** *Contributions: 1 PRs across 1 domain(s)* @@ -86,9 +86,9 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co
-Mansi13-6 +snehal492006 -**[@Mansi13-6](https://github.com/Mansi13-6)** +**[@snehal492006](https://github.com/snehal492006)** *Contributions: 1 PRs across 1 domain(s)* @@ -102,11 +102,13 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co
-Pending +Mansi13-6 -**[Username Pending]** +**[@Mansi13-6](https://github.com/Mansi13-6)** -*Contributions: TBD* +*Contributions: 1 PRs across 1 domain(s)* + +*Domains: Frontend*