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
70 changes: 70 additions & 0 deletions Domains/CompetitiveProgramming/Programs/C++/AssembleTheTable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Problem: Собери стол (Assemble the table)
Platform: Codeforces
Problem Code: 648B
Difficulty: Easy (800 rated)
Link: https://codeforces.com/problemset/problem/648/B

Vasya bought a table with n legs. Each leg consists of two parts that connect to each other. Each part can have any positive length, but it is guaranteed that it is possible to compose n legs of the same length from all 2n parts . When composing a leg , any two parts can be connected to each other. Initially, all the table legs are disassembled, and you are given the lengths of the 2n parts in any order.

Help Vasya assemble all the table legs so that they are all the same length by pairing the given 2n pieces correctly. Each leg must be made of exactly two pieces; using only one piece as a leg is not allowed.

Input data
The first line contains the number n ( 1 ≤  n  ≤ 1000 ) — the number of legs on the table bought by Vasya.

The second line contains a sequence of 2 n positive integers a 1 ,  a 2 , ...,  a 2 n ( 1 ≤  a i  ≤ 100 000 ) — the lengths of the parts of the table legs in random order.

Output data
Print n lines of two integers each—the lengths of the leg pieces that need to be joined together. It is guaranteed that it is always possible to assemble n legs of the same length. If there are multiple answers, you are allowed to print any of them.

Examples:
Input data
3
1 3 2 4 5 3
Output data
1 5
2 4
3 3

Input data
3
1 1 1 2 2 2
Output data
1 2
2 1
1 2

Approach:
1. Sorted the given array.
2. returned pairs of {ith, (size - i)th}, where i < size/2.

Time Complexity: O(n log n)
Space Complexity: O(n)

Contributor: SamaKool
*/

#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;

class Solution
{
public:
int n;
vector<int> sizes;
};
int main()
{
Solution lol;
cin >> lol.n;
lol.sizes.reserve(2*lol.n);
copy_n(istream_iterator<int>(cin), 2*lol.n, back_inserter(lol.sizes));
sort(lol.sizes.begin(), lol.sizes.end());
for(int i = 0; i < lol.n; i++){
cout << lol.sizes[i] << " " << lol.sizes[2*lol.n - i - 1] << endl;
}
return 0;
}
60 changes: 60 additions & 0 deletions Domains/CompetitiveProgramming/Programs/C++/ReverseInteger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Probelm: Reverse Integer
Platform: Leetcode
problem Code: 7
Difficulty: Medium
Link: https://leetcode.com/problems/reverse-integer/description/

Problem Statement:
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.

Assume the environment does not allow you to store 64-bit integers (signed or unsigned).



Example 1:

Input: x = 123
Output: 321
Example 2:

Input: x = -123
Output: -321
Example 3:

Input: x = 120
Output: 21


Constraints:

-231 <= x <= 231 - 1

Approach:
1. extracted the least significant digit(one's place)
2. added it as the most significant digit
3. looped this till completion

Time Complexity: O(n)
Space Complexity: O(1)

Contributor: SamaKool
*/

class Solution {
public:
int reverse(int x) {
long revn = 0;

while(x != 0) {
int lastd = x % 10;
revn = revn * 10 + lastd;
x /= 10;
}
if (revn > INT_MAX || revn < INT_MIN) {
return 0;
}

return revn;
}
};
61 changes: 61 additions & 0 deletions Domains/CompetitiveProgramming/Programs/C++/SortColors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Probelm: Sort Colors
Platform: Leetcode
problem Code: 75
Difficulty: Medium
Link: https://leetcode.com/problems/sort-colors/description/

Problem Statement:
Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.

We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.

You must solve this problem without using the library's sort function.



Example 1:

Input: nums = [2,0,2,1,1,0]
Output: [0,0,1,1,2,2]
Example 2:

Input: nums = [2,0,1]
Output: [0,1,2]


Constraints:

n == nums.length
1 <= n <= 300
nums[i] is either 0, 1, or 2.

Approach:
1. applied a basic sorting algorithm

Time Complexity: O(n^2)
Space Complexity: O(1)

Contributor: SamaKool
*/

class Solution {
public:
void sortColors(vector<int>& nums) {
int n = nums.size();
for (int i = n-1; i >= 1; i--){
int did_swap = 0;
for (int j = 0; j <= i-1; j++){
if(nums[j] > nums[j+1]){
int temp = nums[j];
nums[j] = nums[j+1];
nums[j+1] = temp;
did_swap += 1;
}
}
if(did_swap == 0){
break;
}
}
}
};
36 changes: 19 additions & 17 deletions DomainsLeaderboards/Overall.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,26 @@ Welcome to the ProjectHive Leaderboard! This page automatically tracks all contr
| 🥈 | [@Aaditya-2407](https://github.com/Aaditya-2407) | 6 | 1 (Frontend) | Recent |
| 🥉 | [@Ogagaoghene](https://github.com/Ogagaoghene) | 5 | 1 (Backend) | Recent |
| 4 | [@k4niz](https://github.com/k4niz) | 4 | 4 (AI-ML, AR-VR, FullStack, IoT) | Recent |
| 5 | [@GayatriVitkar](https://github.com/GayatriVitkar) | 3 | 1 (CompetitiveProgramming) | Recent |
| 6 | [@Ansh-1019](https://github.com/Ansh-1019) | 2 | 1 (AI-ML) | Recent |
| 7 | [@vatsalgupta2004](https://github.com/vatsalgupta2004) | 2 | 2 (AI-ML, Frontend) | Recent |
| 8 | [@Dhiraj201226](https://github.com/Dhiraj201226) | 2 | 2 (AI-ML, Frontend) | Recent |
| 5 | [@Ansh-1019](https://github.com/Ansh-1019) | 2 | 1 (AI-ML) | Recent |
| 6 | [@vatsalgupta2004](https://github.com/vatsalgupta2004) | 2 | 2 (AI-ML, Frontend) | Recent |
| 7 | [@Dhiraj201226](https://github.com/Dhiraj201226) | 2 | 2 (AI-ML, Frontend) | Recent |
| 8 | [@GayatriVitkar](https://github.com/GayatriVitkar) | 2 | 1 (CompetitiveProgramming) | Recent |
| 9 | [@Mansi13-6](https://github.com/Mansi13-6) | 2 | 1 (Frontend) | Recent |
| 10 | [@Utkarsh-660](https://github.com/Utkarsh-660) | 2 | 1 (Frontend) | Recent |
| 11 | [@alisha1510](https://github.com/alisha1510) | 2 | 1 (Frontend) | Recent |
| 12 | [@Mmadan128](https://github.com/Mmadan128) | 1 | 1 (AI-ML) | Recent |
| 13 | [@AksharGoyal](https://github.com/AksharGoyal) | 1 | 1 (Backend) | Recent |
| 14 | [@SOHAM-GADEKAR](https://github.com/SOHAM-GADEKAR) | 1 | 1 (Frontend) | Recent |
| 15 | [@GayatriVitkarcd](https://github.com/GayatriVitkarcd) | 1 | 1 (Frontend) | Recent |
| 16 | [@MeghPatel-007](https://github.com/MeghPatel-007) | 1 | 1 (Frontend) | Recent |
| 17 | [@SanjeevDeori](https://github.com/SanjeevDeori) | 1 | 1 (Frontend) | Recent |
| 18 | [@Tanmay-Kad](https://github.com/Tanmay-Kad) | 1 | 1 (Frontend) | Recent |
| 19 | [@Soham-Gadekar](https://github.com/Soham-Gadekar) | 1 | 1 (Frontend) | Recent |
| 20 | [@jeturgavli](https://github.com/jeturgavli) | 1 | 1 (Frontend) | Recent |
| 21 | [@snehal492006](https://github.com/snehal492006) | 1 | 1 (Frontend) | Recent |
| 22 | [@Tanushri1307](https://github.com/Tanushri1307) | 1 | 1 (Frontend) | Recent |
| 23 | [@Keron](https://github.com/Keron) | 1 | 1 (Frontend) | Recent |
| 12 | [@SamaKool](https://github.com/SamaKool) | 1 | 1 (CompetitiveProgramming) | Recent |
| 13 | [@Mmadan128](https://github.com/Mmadan128) | 1 | 1 (AI-ML) | Recent |
| 14 | [@AksharGoyal](https://github.com/AksharGoyal) | 1 | 1 (Backend) | Recent |
| 15 | [@SOHAM-GADEKAR](https://github.com/SOHAM-GADEKAR) | 1 | 1 (Frontend) | Recent |
| 16 | [@GayatriVitkarcd](https://github.com/GayatriVitkarcd) | 1 | 1 (Frontend) | Recent |
| 17 | [@MeghPatel-007](https://github.com/MeghPatel-007) | 1 | 1 (Frontend) | Recent |
| 18 | [@SanjeevDeori](https://github.com/SanjeevDeori) | 1 | 1 (Frontend) | Recent |
| 19 | [@Tanmay-Kad](https://github.com/Tanmay-Kad) | 1 | 1 (Frontend) | Recent |
| 20 | [@Soham-Gadekar](https://github.com/Soham-Gadekar) | 1 | 1 (Frontend) | Recent |
| 21 | [@jeturgavli](https://github.com/jeturgavli) | 1 | 1 (Frontend) | Recent |
| 22 | [@snehal492006](https://github.com/snehal492006) | 1 | 1 (Frontend) | Recent |
| 23 | [@Tanushri1307](https://github.com/Tanushri1307) | 1 | 1 (Frontend) | Recent |
| 24 | [@Keron](https://github.com/Keron) | 1 | 1 (Frontend) | Recent |

---

Expand All @@ -42,7 +43,8 @@ Welcome to the ProjectHive Leaderboard! This page automatically tracks all contr

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

### AI-ML

Expand Down
28 changes: 14 additions & 14 deletions HallOfFame/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ Our Hall of Fame recognizes outstanding individuals who have made significant co

<div align="center">

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

**[@GayatriVitkar](https://github.com/GayatriVitkar)**
**[@Ansh-1019](https://github.com/Ansh-1019)**

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

*Domains: CompetitiveProgramming*
*Domains: AI-ML*

</div>

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

<div align="center">

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

**[@Ansh-1019](https://github.com/Ansh-1019)**
**[@vatsalgupta2004](https://github.com/vatsalgupta2004)**

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

*Domains: AI-ML*
*Domains: AI-ML, Frontend*

</div>

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

<div align="center">

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

**[@vatsalgupta2004](https://github.com/vatsalgupta2004)**
**[@Dhiraj201226](https://github.com/Dhiraj201226)**

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

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

<div align="center">

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

**[@Dhiraj201226](https://github.com/Dhiraj201226)**
**[@GayatriVitkar](https://github.com/GayatriVitkar)**

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

*Domains: AI-ML, Frontend*
*Domains: CompetitiveProgramming*

</div>

Expand Down
Loading