From cbc47a7020707c561464c2d6c9ad80ffb3e01905 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Wed, 26 Apr 2023 00:53:02 +0000 Subject: [PATCH 01/37] Add new daily problem --- .github/data/problems.json | 4 ++++ 04- April/26- Add Digits/.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/26- Add Digits/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 2514d4950..1174ac2c5 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -465,6 +465,10 @@ { "day": "25", "title": "Smallest Number in Infinite Set" + }, + { + "day": "26", + "title": "Add Digits" } ] } \ No newline at end of file diff --git a/04- April/26- Add Digits/.gitkeep b/04- April/26- Add Digits/.gitkeep new file mode 100644 index 000000000..e69de29bb From 6058bf94f2f51de5e1f99559f9a96ff83d650f69 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Thu, 27 Apr 2023 00:56:12 +0000 Subject: [PATCH 02/37] Add new daily problem --- .github/data/problems.json | 4 ++++ 04- April/27- Bulb Switcher/.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/27- Bulb Switcher/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 1174ac2c5..a867e1ce9 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -469,6 +469,10 @@ { "day": "26", "title": "Add Digits" + }, + { + "day": "27", + "title": "Bulb Switcher" } ] } \ No newline at end of file diff --git a/04- April/27- Bulb Switcher/.gitkeep b/04- April/27- Bulb Switcher/.gitkeep new file mode 100644 index 000000000..e69de29bb From ccfb51f998347fde7d005682872740d78e4fcce8 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Thu, 27 Apr 2023 01:09:49 +0000 Subject: [PATCH 03/37] Add new daily problem --- .github/data/problems.json | 4 ++++ 04- April/27- Bulb Switcher/.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/27- Bulb Switcher/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 1174ac2c5..a867e1ce9 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -469,6 +469,10 @@ { "day": "26", "title": "Add Digits" + }, + { + "day": "27", + "title": "Bulb Switcher" } ] } \ No newline at end of file diff --git a/04- April/27- Bulb Switcher/.gitkeep b/04- April/27- Bulb Switcher/.gitkeep new file mode 100644 index 000000000..e69de29bb From 95bc7b9f1ec7c406f4e4029440cddd102bab5e9f Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Fri, 28 Apr 2023 00:45:55 +0000 Subject: [PATCH 04/37] Add new daily problem --- .github/data/problems.json | 4 ++++ 04- April/28- Similar String Groups/.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/28- Similar String Groups/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index a867e1ce9..ada23e045 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -473,6 +473,10 @@ { "day": "27", "title": "Bulb Switcher" + }, + { + "day": "28", + "title": "Similar String Groups" } ] } \ No newline at end of file diff --git a/04- April/28- Similar String Groups/.gitkeep b/04- April/28- Similar String Groups/.gitkeep new file mode 100644 index 000000000..e69de29bb From 2c59a3b22aa2a314f50be83729b515e738add018 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Fri, 28 Apr 2023 01:00:39 +0000 Subject: [PATCH 05/37] Add new daily problem --- .github/data/problems.json | 4 ++++ 04- April/28- Similar String Groups/.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/28- Similar String Groups/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index a867e1ce9..ada23e045 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -473,6 +473,10 @@ { "day": "27", "title": "Bulb Switcher" + }, + { + "day": "28", + "title": "Similar String Groups" } ] } \ No newline at end of file diff --git a/04- April/28- Similar String Groups/.gitkeep b/04- April/28- Similar String Groups/.gitkeep new file mode 100644 index 000000000..e69de29bb From d1b6849ebeb25d02eddf91c51d88b328e481fbb7 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Sat, 29 Apr 2023 00:32:54 +0000 Subject: [PATCH 06/37] Add new daily problem --- .github/data/problems.json | 4 ++++ .../.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index ada23e045..acff9a3db 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -477,6 +477,10 @@ { "day": "28", "title": "Similar String Groups" + }, + { + "day": "29", + "title": "Checking Existence of Edge Length Limited Paths" } ] } \ No newline at end of file diff --git a/04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep b/04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep new file mode 100644 index 000000000..e69de29bb From f27e7e6ea80b43825056865cfa56b7b775305e71 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Sat, 29 Apr 2023 00:52:53 +0000 Subject: [PATCH 07/37] Add new daily problem --- .github/data/problems.json | 4 ++++ .../.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index ada23e045..acff9a3db 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -477,6 +477,10 @@ { "day": "28", "title": "Similar String Groups" + }, + { + "day": "29", + "title": "Checking Existence of Edge Length Limited Paths" } ] } \ No newline at end of file diff --git a/04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep b/04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep new file mode 100644 index 000000000..e69de29bb From f46b28beaf40dabf28813268217c6217d4f97d20 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Sat, 29 Apr 2023 01:02:56 +0000 Subject: [PATCH 08/37] Add new daily problem --- .github/data/problems.json | 4 ++++ .../.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index ada23e045..acff9a3db 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -477,6 +477,10 @@ { "day": "28", "title": "Similar String Groups" + }, + { + "day": "29", + "title": "Checking Existence of Edge Length Limited Paths" } ] } \ No newline at end of file diff --git a/04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep b/04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep new file mode 100644 index 000000000..e69de29bb From 0ec2d964b3f51bdf8289236c4a9650feaf9665d3 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Sat, 29 Apr 2023 01:35:40 +0000 Subject: [PATCH 09/37] Add new daily problem --- .github/data/problems.json | 4 ++++ .../.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index ada23e045..acff9a3db 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -477,6 +477,10 @@ { "day": "28", "title": "Similar String Groups" + }, + { + "day": "29", + "title": "Checking Existence of Edge Length Limited Paths" } ] } \ No newline at end of file diff --git a/04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep b/04- April/29- Checking Existence of Edge Length Limited Paths/.gitkeep new file mode 100644 index 000000000..e69de29bb From 84ccd04502988e5683dd3b8e85deea5ec8d05b3c Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Sun, 30 Apr 2023 00:33:10 +0000 Subject: [PATCH 10/37] Add new daily problem --- .github/data/problems.json | 4 ++++ .../.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index acff9a3db..95f087c63 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -481,6 +481,10 @@ { "day": "29", "title": "Checking Existence of Edge Length Limited Paths" + }, + { + "day": "30", + "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" } ] } \ No newline at end of file diff --git a/04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep b/04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep new file mode 100644 index 000000000..e69de29bb From 7f6fa4f71eac5d2a10019fb037bb63a0264ed294 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Sun, 30 Apr 2023 00:50:01 +0000 Subject: [PATCH 11/37] Add new daily problem --- .github/data/problems.json | 4 ++++ .../.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index acff9a3db..95f087c63 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -481,6 +481,10 @@ { "day": "29", "title": "Checking Existence of Edge Length Limited Paths" + }, + { + "day": "30", + "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" } ] } \ No newline at end of file diff --git a/04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep b/04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep new file mode 100644 index 000000000..e69de29bb From b412cc2917fb637118f9c308827803ecd117186f Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Sun, 30 Apr 2023 01:05:32 +0000 Subject: [PATCH 12/37] Add new daily problem --- .github/data/problems.json | 4 ++++ .../.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index acff9a3db..95f087c63 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -481,6 +481,10 @@ { "day": "29", "title": "Checking Existence of Edge Length Limited Paths" + }, + { + "day": "30", + "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" } ] } \ No newline at end of file diff --git a/04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep b/04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep new file mode 100644 index 000000000..e69de29bb From e972ccb9bb23cb583c935575100c851aa1b56ff8 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Sun, 30 Apr 2023 01:36:09 +0000 Subject: [PATCH 13/37] Add new daily problem --- .github/data/problems.json | 4 ++++ .../.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index acff9a3db..95f087c63 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -481,6 +481,10 @@ { "day": "29", "title": "Checking Existence of Edge Length Limited Paths" + }, + { + "day": "30", + "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" } ] } \ No newline at end of file diff --git a/04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep b/04- April/30- Remove Max Number of Edges to Keep Graph Fully Traversable/.gitkeep new file mode 100644 index 000000000..e69de29bb From 8770d1b2a56b50d3dbac8d788a414514f59a6f91 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Mon, 1 May 2023 00:42:50 +0000 Subject: [PATCH 14/37] Add new daily problem --- .github/data/problems.json | 6 ++++++ .../.gitkeep | 0 2 files changed, 6 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 95f087c63..2c57e7c4d 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -486,5 +486,11 @@ "day": "30", "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" } + ], + "05- May": [ + { + "day": "01", + "title": "Average Salary Excluding the Minimum and Maximum Salary" + } ] } \ No newline at end of file diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep new file mode 100644 index 000000000..e69de29bb From 1a3568a472312f2170e6e2467c6baf6b9645acc0 Mon Sep 17 00:00:00 2001 From: aboelsoud Date: Mon, 1 May 2023 03:50:31 +0300 Subject: [PATCH 15/37] add the 1'st day problem solution --- ...and Maximum Salary (Mahmoud Aboelsoud).cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Mahmoud Aboelsoud).cpp diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Mahmoud Aboelsoud).cpp b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Mahmoud Aboelsoud).cpp new file mode 100644 index 000000000..c67bba232 --- /dev/null +++ b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Mahmoud Aboelsoud).cpp @@ -0,0 +1,21 @@ +// Author: Mahmoud Aboelsoud + +class Solution { +public: + double average(vector& salary) { + // we need find the avaerage of all salaries except the minimum and maximum salaries + // we can find the minimum and maximum salaries using min_element and max_element + // then we can find the average of all salaries except the minimum and maximum salaries + + + // mn: minimum salary, mx: maximum salary + int mn = *min_element(salary.begin(), salary.end()), mx = *max_element(salary.begin(), salary.end()); + // sum: sum of all salaries except the minimum and maximum salaries + double sum = 0; + // loop over all salaries and add them to sum except the minimum and maximum salaries + for(auto&i: salary) sum += i * (i != mn && i != mx); + + // return the average of all salaries except the minimum and maximum salaries + return sum / (salary.size() - 2); + } +}; From 3a4c5407886b87adcabeae8a29f06f25d0a24dfb Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Mon, 1 May 2023 00:56:21 +0000 Subject: [PATCH 16/37] Add new daily problem --- .github/data/problems.json | 6 ++++++ .../.gitkeep | 0 2 files changed, 6 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 95f087c63..2c57e7c4d 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -486,5 +486,11 @@ "day": "30", "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" } + ], + "05- May": [ + { + "day": "01", + "title": "Average Salary Excluding the Minimum and Maximum Salary" + } ] } \ No newline at end of file diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep new file mode 100644 index 000000000..e69de29bb From 2cbb396dd8d61c917d84ba3d72495c532d9344ba Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Mon, 1 May 2023 01:05:22 +0000 Subject: [PATCH 17/37] Add new daily problem --- .github/data/problems.json | 6 ++++++ .../.gitkeep | 0 2 files changed, 6 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 95f087c63..2c57e7c4d 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -486,5 +486,11 @@ "day": "30", "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" } + ], + "05- May": [ + { + "day": "01", + "title": "Average Salary Excluding the Minimum and Maximum Salary" + } ] } \ No newline at end of file diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep new file mode 100644 index 000000000..e69de29bb From 9e55134fc2a71b938a8811cf4055c81097df1fde Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Mon, 1 May 2023 01:11:43 +0000 Subject: [PATCH 18/37] Add new daily problem --- .github/data/problems.json | 6 ++++++ .../.gitkeep | 0 2 files changed, 6 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 95f087c63..2c57e7c4d 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -486,5 +486,11 @@ "day": "30", "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" } + ], + "05- May": [ + { + "day": "01", + "title": "Average Salary Excluding the Minimum and Maximum Salary" + } ] } \ No newline at end of file diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep new file mode 100644 index 000000000..e69de29bb From 9f0519036fe78c0b673c9d4db1c7214493a8d56b Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Mon, 1 May 2023 01:39:00 +0000 Subject: [PATCH 19/37] Add new daily problem --- .github/data/problems.json | 6 ++++++ .../.gitkeep | 0 2 files changed, 6 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 95f087c63..2c57e7c4d 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -486,5 +486,11 @@ "day": "30", "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" } + ], + "05- May": [ + { + "day": "01", + "title": "Average Salary Excluding the Minimum and Maximum Salary" + } ] } \ No newline at end of file diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/.gitkeep new file mode 100644 index 000000000..e69de29bb From f988b30eeb96e8a27ab350dc442de269587694e8 Mon Sep 17 00:00:00 2001 From: Omar Sanad <108091921+OmarSanad3@users.noreply.github.com> Date: Mon, 1 May 2023 05:06:36 +0200 Subject: [PATCH 20/37] Added Omar Sanad's Solution to May 1st --- ...Minimum and Maximum Salary(Omar Sanad).cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary(Omar Sanad).cpp diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary(Omar Sanad).cpp b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary(Omar Sanad).cpp new file mode 100644 index 000000000..3d2d3a1eb --- /dev/null +++ b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary(Omar Sanad).cpp @@ -0,0 +1,20 @@ +// author : Omar Sanad +class Solution { +public: + double average(vector& salary) { + + // sort the array salary, to easily exclude the minimum and maximum element + sort(salary.begin(), salary.end()); + + // declare a variable to store the sum of all salaries excluding the min and max + int sum = 0; + + // iterate over all salaries except the min and max, then add up to "sum" + for (int i = 1; i < salary.size() - 1; i++) + sum += salary[i]; + + // return sum divided by the number of salaries I considered + // number of salaries I considered = the number of all salaries excluding the min and max + return sum / (1.0 * (salary.size() - 2)); + } +}; From 7de5f373a216c32814aae92015c5102296f160d5 Mon Sep 17 00:00:00 2001 From: Omar Sanad <108091921+OmarSanad3@users.noreply.github.com> Date: Mon, 1 May 2023 05:09:48 +0200 Subject: [PATCH 21/37] Edited the name of the file. Just added one space before the opening bracket of my name. --- ...ary Excluding the Minimum and Maximum Salary (Omar Sanad).cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/{01- Average Salary Excluding the Minimum and Maximum Salary(Omar Sanad).cpp => 01- Average Salary Excluding the Minimum and Maximum Salary (Omar Sanad).cpp} (100%) diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary(Omar Sanad).cpp b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Omar Sanad).cpp similarity index 100% rename from 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary(Omar Sanad).cpp rename to 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Omar Sanad).cpp From 0482521ba238d7c9fee3930c59e698f72a11af6c Mon Sep 17 00:00:00 2001 From: Ibrahim Khaild <103538501+Hima-khalid@users.noreply.github.com> Date: Mon, 1 May 2023 06:38:39 +0200 Subject: [PATCH 22/37] first day on 5th month --- ...nimum and Maximum Salary (Ibrahim Khalid).cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ibrahim Khalid).cpp diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ibrahim Khalid).cpp b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ibrahim Khalid).cpp new file mode 100644 index 000000000..eb30272ca --- /dev/null +++ b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ibrahim Khalid).cpp @@ -0,0 +1,16 @@ +// author :- Ibrahim Khalid +class Solution { +public: + double average(vector& salary) { + // sort to excluding the minimum and maximum salary + sort(salary.begin(),salary.end()); + // store summation + long double sum=0; + for(int i=1;i Date: Mon, 1 May 2023 06:43:19 +0200 Subject: [PATCH 23/37] first day on 5th month --- ...xcluding the Minimum and Maximum Salary (Ibrahim Khalid).cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ibrahim Khalid).cpp b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ibrahim Khalid).cpp index eb30272ca..398498a8f 100644 --- a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ibrahim Khalid).cpp +++ b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ibrahim Khalid).cpp @@ -1,4 +1,4 @@ -// author :- Ibrahim Khalid +// Author: Ibrahim Khalid class Solution { public: double average(vector& salary) { From ae60db366a65e4019168ab6dda309e90312add9e Mon Sep 17 00:00:00 2001 From: Noura Algohary Date: Mon, 1 May 2023 12:03:53 +0300 Subject: [PATCH 24/37] add day 1 --- ...ry Excluding the Minimum and Maximum Salary (cpp).cpp | 9 +++++++++ ...lary Excluding the Minimum and Maximum Salary (py).py | 4 ++++ 2 files changed, 13 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (cpp).cpp create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (py).py diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (cpp).cpp b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (cpp).cpp new file mode 100644 index 000000000..4e06ee96a --- /dev/null +++ b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (cpp).cpp @@ -0,0 +1,9 @@ +// Author: Noura Algohary +class Solution { +public: + double average(vector& salary) { + //accumulate returns the sum of elements of vector "salary" + + return double((accumulate(salary.begin(), salary.end(), 0) - *max_element(salary.begin(), salary.end()) - *min_element(salary.begin(), salary.end()))) / (salary.size() - 2); + } +}; \ No newline at end of file diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (py).py b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (py).py new file mode 100644 index 000000000..40a8c0cd4 --- /dev/null +++ b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (py).py @@ -0,0 +1,4 @@ +# Author: Noura Algohary +class Solution: + def average(self, salary: List[int]) -> float: + return (sum(salary) - min(salary) - max(salary)) / (len(salary) - 2) \ No newline at end of file From 470b3c68413ef416f3f0e9ebb68a160ce58541ff Mon Sep 17 00:00:00 2001 From: Omar wael <63034210+omar2818@users.noreply.github.com> Date: Mon, 1 May 2023 11:58:49 +0200 Subject: [PATCH 25/37] 01- Average Salary Excluding the Minimum and Maximum Salary (Omar Wael).cpp --- ...Minimum and Maximum Salary (Omar Wael).cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Omar Wael).cpp diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Omar Wael).cpp b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Omar Wael).cpp new file mode 100644 index 000000000..a66049b37 --- /dev/null +++ b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Omar Wael).cpp @@ -0,0 +1,28 @@ +// Author : Omar Wael +// leetcode account : https://leetcode.com/OmarWael1/ + +class Solution { +public: + double average(vector& salary) { + int mn=INT_MAX,mx=0; + double ave=0; + for(auto i:salary){ + // get min element + if(imx){ + mx=i; + } + // add current element to the sum + ave+=i; + } + // subtract min and max element from the sum + ave-=(mx+mn); + // devide the sum by the number of elements + ave/=salary.size()-2; + // return the average + return ave; + } +}; From 03aed87f5f8a47968e2aed15df808a878cf85e37 Mon Sep 17 00:00:00 2001 From: Osama Ayman Date: Mon, 1 May 2023 17:29:02 +0300 Subject: [PATCH 26/37] Added my sol to 1 May --- ...imum and Maximum Salary (Osama Ayman).java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Osama Ayman).java diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Osama Ayman).java b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Osama Ayman).java new file mode 100644 index 000000000..150cdb694 --- /dev/null +++ b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Osama Ayman).java @@ -0,0 +1,24 @@ +// Author: Osama Ayman +// Time: O(n) +// Space: O(1) +class Solution { + public double average(int[] salary) { + int max = -1, min = Integer.MAX_VALUE; + double res = 0; + for(int sal: salary){ + // updating max + max = Math.max(max, sal); + // updating min + min = Math.min(min, sal); + // adding all salaries + res += sal; + } + // removing the max + res -= max; + // removing the min + res -= min; + // calculating the average + res /= (salary.length-2); + return res; + } +} \ No newline at end of file From 6b295b7c0352f6eda7e0802dfbbe4a2d8957ed0b Mon Sep 17 00:00:00 2001 From: Ahmed Hossam <63050133+7oSkaaa@users.noreply.github.com> Date: Mon, 1 May 2023 16:58:21 +0300 Subject: [PATCH 27/37] Create 01- Average Salary Excluding the Minimum and Maximum Salary (Ahmed Hossam).cpp --- ...imum and Maximum Salary (Ahmed Hossam).cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ahmed Hossam).cpp diff --git a/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ahmed Hossam).cpp b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ahmed Hossam).cpp new file mode 100644 index 000000000..b5991f45e --- /dev/null +++ b/05- May/01- Average Salary Excluding the Minimum and Maximum Salary/01- Average Salary Excluding the Minimum and Maximum Salary (Ahmed Hossam).cpp @@ -0,0 +1,19 @@ +// Author: Ahmed Hossam + +class Solution { +public: + // This function calculates the average of a vector of integers by sorting it and removing the minimum and maximum values. + double average(vector& salary) { + + // Calculate the sum of all the elements in the vector except for the minimum and maximum values. + double sum = 0, n = salary.size() - 2; + sort(salary.begin(), salary.end()); + for(auto& i : salary) + sum += i; + sum -= salary.front() + salary.back(); + + // Return the average by dividing the sum by the number of elements in the vector minus 2. + return sum / n; + } + +}; From fbbfb91de4c6ea6d2819cafc8ce4bee9908c307d Mon Sep 17 00:00:00 2001 From: Ahmed Hossam <63050133+7oSkaaa@users.noreply.github.com> Date: Mon, 1 May 2023 16:59:46 +0300 Subject: [PATCH 28/37] Create README.md --- 05- May/README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 05- May/README.md diff --git a/05- May/README.md b/05- May/README.md new file mode 100644 index 000000000..6e237cee4 --- /dev/null +++ b/05- May/README.md @@ -0,0 +1,23 @@ +# LeetCode Daily Challenge Problems for May + +

+ +## Workflow Checking + + + +

+ +## Problems: From c73f61227f5acd932baa451c884e9c48e84b4a11 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Mon, 1 May 2023 14:00:36 +0000 Subject: [PATCH 29/37] Add new daily problem to README --- 05- May/README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/05- May/README.md b/05- May/README.md index 6e237cee4..e3c8d3ccb 100644 --- a/05- May/README.md +++ b/05- May/README.md @@ -21,3 +21,40 @@

## Problems: + +
+

+ +## 01) [Average Salary Excluding the Minimum and Maximum Salary](https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/) + +### Difficulty + +![](https://img.shields.io/badge/Easy-green?style=for-the-badge) + +### Related Topic + +`Array` `Sorting` + +### Code + + +```cpp +class Solution { +public: + // This function calculates the average of a vector of integers by sorting it and removing the minimum and maximum values. + double average(vector& salary) { + + // Calculate the sum of all the elements in the vector except for the minimum and maximum values. + double sum = 0, n = salary.size() - 2; + sort(salary.begin(), salary.end()); + for(auto& i : salary) + sum += i; + sum -= salary.front() + salary.back(); + + // Return the average by dividing the sum by the number of elements in the vector minus 2. + return sum / n; + } + +}; +``` + \ No newline at end of file From c3c75f3979394539a01a10d0fde637859e102be8 Mon Sep 17 00:00:00 2001 From: Ahmed Hossam <63050133+7oSkaaa@users.noreply.github.com> Date: Mon, 1 May 2023 17:00:49 +0300 Subject: [PATCH 30/37] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 46dcbc1bd..dd02d8d60 100644 --- a/README.md +++ b/README.md @@ -48,4 +48,5 @@ https://user-images.githubusercontent.com/94416115/210334779-16a94ab4-5c24-4a90- - [**February**](https://github.com/7oSkaaa/LeetCode_DailyChallenge_2023/tree/main/02-%20February) - [**March**](https://github.com/7oSkaaa/LeetCode_DailyChallenge_2023/tree/main/03-%20March) - [**April**](https://github.com/7oSkaaa/LeetCode_DailyChallenge_2023/tree/main/04-%20April) +- [**May**](https://github.com/7oSkaaa/LeetCode_DailyChallenge_2023/tree/main/05-%20May)
From fcfd31a29aab6476504aea0391b514747b350ca4 Mon Sep 17 00:00:00 2001 From: Ahmed Hossam <63050133+7oSkaaa@users.noreply.github.com> Date: Mon, 1 May 2023 17:01:34 +0300 Subject: [PATCH 31/37] Update README.md --- 04- April/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/04- April/README.md b/04- April/README.md index 3fa254dcf..b34749c66 100644 --- a/04- April/README.md +++ b/04- April/README.md @@ -23,7 +23,6 @@ ## Problems: 1. **[Binary Search](#01--binary-search)** - 1. **[Successful Pairs of Spells and Potions](#02--successful-pairs-of-spells-and-potions)** 1. **[Boats to Save People](#03--boats-to-save-people)** 1. **[Optimal Partition of String](#04--optimal-partition-of-string)** From 45abad3183c9f7fe9c7db852a649d8c1cac3c63c Mon Sep 17 00:00:00 2001 From: Ahmed Hossam <63050133+7oSkaaa@users.noreply.github.com> Date: Mon, 1 May 2023 17:02:28 +0300 Subject: [PATCH 32/37] Update README.md --- 05- May/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/05- May/README.md b/05- May/README.md index e3c8d3ccb..2ca4c9ad3 100644 --- a/05- May/README.md +++ b/05- May/README.md @@ -21,6 +21,7 @@

## Problems: +1. **[Average Salary Excluding the Minimum and Maximum Salary](#01--average-salary-excluding-the-minimum-and-maximum-salary)**


@@ -57,4 +58,4 @@ public: }; ``` - \ No newline at end of file + From 695667d934f47c0a7ae557df36b9cbd3701cde9b Mon Sep 17 00:00:00 2001 From: Noura Algohary Date: Tue, 2 May 2023 03:23:48 +0300 Subject: [PATCH 33/37] add day 2 --- ...e Product of an Array (Noura Algohary).cpp | 22 +++++++++++++++++++ ...he Product of an Array (Noura Algohary).py | 14 ++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).cpp create mode 100644 05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).py diff --git a/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).cpp b/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).cpp new file mode 100644 index 000000000..a7ebcfdb8 --- /dev/null +++ b/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).cpp @@ -0,0 +1,22 @@ +// Author: Noura Algohary +class Solution { +public: + int arraySign(vector& nums) { + int signCounter = 0; + + for(int num : nums) + { + // if one zero appears, the result is zero + if(num==0) + return 0; + else if(num<0) + signCounter++; + } + + // if negative numbers are of odd count, the result is negative + if (signCounter%2==0) + return 1; + else + return -1; + } +}; \ No newline at end of file diff --git a/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).py b/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).py new file mode 100644 index 000000000..7e83fd589 --- /dev/null +++ b/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).py @@ -0,0 +1,14 @@ +# Author: Noura Algohary +class Solution: + def arraySign(self, nums: List[int]) -> int: + signCounter = 0 + + for num in nums: + # if one zero appears, the result is zero + if num == 0: + return 0 + elif num < 0: + signCounter += 1 + + # if negative numbers are of odd count, the result is negative + return 1 if signCounter % 2 == 0 else -1 \ No newline at end of file From 7e418f2d9582173104b225ff48890ef67eceef31 Mon Sep 17 00:00:00 2001 From: Noura Algohary Date: Tue, 2 May 2023 03:27:19 +0300 Subject: [PATCH 34/37] name modified --- ...e Product of an Array (Noura Algohary).cpp | 22 +++++++++++++++++++ ...he Product of an Array (Noura Algohary).py | 14 ++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 05- May/02- Sign of the Product of an Array/02- Sign of the Product of an Array (Noura Algohary).cpp create mode 100644 05- May/02- Sign of the Product of an Array/02- Sign of the Product of an Array (Noura Algohary).py diff --git a/05- May/02- Sign of the Product of an Array/02- Sign of the Product of an Array (Noura Algohary).cpp b/05- May/02- Sign of the Product of an Array/02- Sign of the Product of an Array (Noura Algohary).cpp new file mode 100644 index 000000000..a7ebcfdb8 --- /dev/null +++ b/05- May/02- Sign of the Product of an Array/02- Sign of the Product of an Array (Noura Algohary).cpp @@ -0,0 +1,22 @@ +// Author: Noura Algohary +class Solution { +public: + int arraySign(vector& nums) { + int signCounter = 0; + + for(int num : nums) + { + // if one zero appears, the result is zero + if(num==0) + return 0; + else if(num<0) + signCounter++; + } + + // if negative numbers are of odd count, the result is negative + if (signCounter%2==0) + return 1; + else + return -1; + } +}; \ No newline at end of file diff --git a/05- May/02- Sign of the Product of an Array/02- Sign of the Product of an Array (Noura Algohary).py b/05- May/02- Sign of the Product of an Array/02- Sign of the Product of an Array (Noura Algohary).py new file mode 100644 index 000000000..7e83fd589 --- /dev/null +++ b/05- May/02- Sign of the Product of an Array/02- Sign of the Product of an Array (Noura Algohary).py @@ -0,0 +1,14 @@ +# Author: Noura Algohary +class Solution: + def arraySign(self, nums: List[int]) -> int: + signCounter = 0 + + for num in nums: + # if one zero appears, the result is zero + if num == 0: + return 0 + elif num < 0: + signCounter += 1 + + # if negative numbers are of odd count, the result is negative + return 1 if signCounter % 2 == 0 else -1 \ No newline at end of file From 66f99b709c77271cd0f96fd125fa6b27df2ab1b2 Mon Sep 17 00:00:00 2001 From: Noura Algohary Date: Tue, 2 May 2023 03:30:44 +0300 Subject: [PATCH 35/37] modified folder name --- ...e Product of an Array (Noura Algohary).cpp | 22 ------------------- ...he Product of an Array (Noura Algohary).py | 14 ------------ 2 files changed, 36 deletions(-) delete mode 100644 05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).cpp delete mode 100644 05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).py diff --git a/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).cpp b/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).cpp deleted file mode 100644 index a7ebcfdb8..000000000 --- a/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Author: Noura Algohary -class Solution { -public: - int arraySign(vector& nums) { - int signCounter = 0; - - for(int num : nums) - { - // if one zero appears, the result is zero - if(num==0) - return 0; - else if(num<0) - signCounter++; - } - - // if negative numbers are of odd count, the result is negative - if (signCounter%2==0) - return 1; - else - return -1; - } -}; \ No newline at end of file diff --git a/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).py b/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).py deleted file mode 100644 index 7e83fd589..000000000 --- a/05- May/2- Sign of the Product of an Array/2- Sign of the Product of an Array (Noura Algohary).py +++ /dev/null @@ -1,14 +0,0 @@ -# Author: Noura Algohary -class Solution: - def arraySign(self, nums: List[int]) -> int: - signCounter = 0 - - for num in nums: - # if one zero appears, the result is zero - if num == 0: - return 0 - elif num < 0: - signCounter += 1 - - # if negative numbers are of odd count, the result is negative - return 1 if signCounter % 2 == 0 else -1 \ No newline at end of file From 38bd39e6440f48d75d164f23ddaf004f03cc287d Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Tue, 2 May 2023 00:54:33 +0000 Subject: [PATCH 36/37] Add new daily problem --- .github/data/problems.json | 4 ++++ 05- May/02- Sign of the Product of an Array/.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 05- May/02- Sign of the Product of an Array/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 2c57e7c4d..3618059de 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -491,6 +491,10 @@ { "day": "01", "title": "Average Salary Excluding the Minimum and Maximum Salary" + }, + { + "day": "02", + "title": "Sign of the Product of an Array" } ] } \ No newline at end of file diff --git a/05- May/02- Sign of the Product of an Array/.gitkeep b/05- May/02- Sign of the Product of an Array/.gitkeep new file mode 100644 index 000000000..e69de29bb From fa8dc17b3c0648377ea7fe94558751b450ac1518 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Tue, 2 May 2023 01:18:45 +0000 Subject: [PATCH 37/37] Add new daily problem --- .github/data/problems.json | 4 ++++ 05- May/02- Sign of the Product of an Array/.gitkeep | 0 2 files changed, 4 insertions(+) create mode 100644 05- May/02- Sign of the Product of an Array/.gitkeep diff --git a/.github/data/problems.json b/.github/data/problems.json index 2c57e7c4d..3618059de 100644 --- a/.github/data/problems.json +++ b/.github/data/problems.json @@ -491,6 +491,10 @@ { "day": "01", "title": "Average Salary Excluding the Minimum and Maximum Salary" + }, + { + "day": "02", + "title": "Sign of the Product of an Array" } ] } \ No newline at end of file diff --git a/05- May/02- Sign of the Product of an Array/.gitkeep b/05- May/02- Sign of the Product of an Array/.gitkeep new file mode 100644 index 000000000..e69de29bb