leetcode

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

commit 0c52646ebc39c9c179e7edabb91b3ba2c8029a56
parent 39d5f71aac08064a4f2b38e5dd484fcb59be9fc3
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed, 13 Dec 2023 16:53:58 +0000

Daily Problem

Diffstat:
AProblems/1582.cpp | 26++++++++++++++++++++++++++
MREADME.md | 1+
2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/Problems/1582.cpp b/Problems/1582.cpp @@ -0,0 +1,26 @@ +class Solution { + public: + int numSpecial(const vector<vector<int>> &mat) const { + const int n = mat.size(), m = mat[0].size(); + int row[101] = {0}, col[101] = {0}; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + if (mat[i][j]) { + row[i]++; + col[j]++; + } + } + } + + int res = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + if (mat[i][j] && row[i] == 1 && col[j] == 1) { + res++; + } + } + } + return res; + } +}; diff --git a/README.md b/README.md @@ -732,6 +732,7 @@ for solving problems. | 1578 | Medium | [Minimum Time to Make Rope Colorful](Problems/1578.cpp) | | 1579 | Hard | [Remove Max Number of Edges to Keep Graph Fully Traversable](Problems/1579.cpp) | | 1581 | Easy | [Customer Who Visited but Did Not Make Any Transactions](Problems/1581.cpp) | +| 1582 | Easy | [Special Positions in a Binary Matrix](Problems/1582.cpp) | | 1583 | Medium | [Count Unhappy Friends](Problems/1583.cpp) | | 1584 | Medium | [Min Cost to Connect All Points](Problems/1584.cpp) | | 1587 | Easy | [Bank Account Summary II](Problems/1587.cpp) |