-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy path0176_Problem_1.cpp
More file actions
28 lines (24 loc) · 893 Bytes
/
0176_Problem_1.cpp
File metadata and controls
28 lines (24 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// code_report Solution
// Problem Link (Contest): https://leetcode.com/contest/weekly-contest-176/problems/count-negative-numbers-in-a-sorted-matrix/
// Problem Link (Practice): https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix/
// Godbolt Link: https://godbolt.org/z/sx6b9K
// Video Link: https://youtu.be/pDbDtGn1PXk
#include <vector>
#include <range/v3/view/filter.hpp>
#include <range/v3/view/join.hpp>
namespace rv = ranges::views;
namespace hs {
auto length() {
return ranges::make_pipeable([](auto&& rng) {
return std::distance(
ranges::begin(rng),
ranges::end(rng));
});
}
}
auto countNegatives(std::vector<std::vector<int>> const& grid) -> int {
return grid
| rv::join
| rv::filter([](auto e) { return e < 0; })
| hs::length();
}