This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |