From 695667d934f47c0a7ae557df36b9cbd3701cde9b Mon Sep 17 00:00:00 2001 From: Noura Algohary Date: Tue, 2 May 2023 03:23:48 +0300 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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 fa8dc17b3c0648377ea7fe94558751b450ac1518 Mon Sep 17 00:00:00 2001 From: 7oSkaaa Date: Tue, 2 May 2023 01:18:45 +0000 Subject: [PATCH 4/4] 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