leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit b78de2ac5034da415e829086fc414b0ae53d9e10
parent 70acc1c9831498cf6d4b2884b4ee8d864c299b8c
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Tue,  2 May 2023 09:50:54 +0200

Daily Problem

Diffstat:
AProblems/1822.cpp | 11+++++++++++
MREADME.md | 2+-
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Problems/1822.cpp b/Problems/1822.cpp @@ -0,0 +1,11 @@ +class Solution { +public: + int arraySign(vector<int> &nums) { + int sign = 1; + for (auto num : nums) { + if (num == 0) return 0; + if (num < 0) sign = -sign; + } + return sign; + } +}; diff --git a/README.md b/README.md @@ -475,6 +475,7 @@ for solving problems. | 1768 | Easy | [Merge Strings Alternately](Problems/1768.cpp) | | 1786 | Medium | [Number of Restricted Paths From First to Last Node](Problems/1786.cpp) | | 1791 | Easy | [Find Center of Star Graph](Problems/1791.cpp) | +| 1822 | Easy | [Sign of the Product of an Array](Problems/1822.cpp) | | 1823 | Medium | [Find the Winner of the Circular Game](Problems/1823.cpp) | | 1833 | Medium | [Maximum Ice Cream Bars](Problems/1833.cpp) | | 1834 | Medium | [Single-Threaded CPU](Problems/1834.cpp) | @@ -529,4 +530,3 @@ for solving problems. | 2477 | Medium | [Minimum Fuel Cost to Report to the Capital](Problems/2477.cpp) | | 2492 | Medium | [Minimum Score of a Path Between Two Cities](Problems/2492.cpp) | | 2497 | Medium | [Maximum Star Sum of a Graph](Problems/2497.cpp) | -