Skip to content

Instantly share code, notes, and snippets.

View yruslan's full-sized avatar

Ruslan Yushchenko yruslan

  • Prague, Czech Republic
View GitHub Profile
class Solution {
public:
int soldiers(const vector<int>& row) {
// Need to use greater<int>() since the vector is descending, not assending
// It also explains lower_bound of 0 instead of 1 or 0.5
auto it = lower_bound(row.begin(), row.end(), 0, greater<int>());
return it-row.begin();
}
vector<int> kWeakestRows(vector<vector<int>>& mat, int k) {