leetcode

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

commit 01903c0ca25df04b312d414ea722d2f78d84ddfd
parent e868b4b50ad12e2a0a24900dc565f6bb2cbf4a90
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Tue,  9 Jul 2024 12:25:30 +0200

1 Random Problem

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

diff --git a/Problems/3195.cpp b/Problems/3195.cpp @@ -0,0 +1,26 @@ +static const auto _ = []() { + std::ios_base::sync_with_stdio(false); + std::cout.tie(nullptr); + std::cin.tie(nullptr); + return true; +}(); + +class Solution { + public: + int minimumArea(const vector<vector<int>> &grid) const { + int minix = INT_MAX, maxix = INT_MIN; + int miniy = INT_MAX, maxiy = INT_MIN; + + for (int i = 0; i < size(grid); i++) { + for (int j = 0; j < size(grid[0]); j++) { + if (!grid[i][j]) continue; + minix = min(minix, i); + maxix = max(maxix, i); + miniy = min(miniy, j); + maxiy = max(maxiy, j); + } + } + + return (maxix - minix + 1) * (maxiy - miniy + 1); + } +}; diff --git a/README.md b/README.md @@ -1281,4 +1281,5 @@ for solving problems. | 3106 | Medium | [Lexicographically Smallest String After Operations With Constraint](Problems/3106.cpp) | | 3110 | Easy | [Score of a String](Problems/3110.cpp) | | 3111 | Medium | [Minimum Rectangles to Cover Points](Problems/3111.cpp) | +| 3195 | Medium | [Find the Minimum Area to Cover All Ones I](Problems/3195.cpp) | | 3211 | Medium | [Generate Binary Strings Without Adjacent Zeros](Problems/3211.cpp) |