problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::the_number_of_weak_characters_in_the_game::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int numberOfWeakCharacters (vector< vector< int > > &properties)
 

详细描述

在文件 leetcode.h762 行定义.

成员函数说明

◆ numberOfWeakCharacters()

int leetcode::the_number_of_weak_characters_in_the_game::Solution::numberOfWeakCharacters ( vector< vector< int > > &  properties)
static

< 最大防御值

在文件 leetcode.cpp1765 行定义.

1765 {
1766 //按攻击值从大到小排序。攻击值相同时,按照其防御值从小到大排序
1767 sort(properties.begin(), properties.end(), [](const vector<int> &a, const vector<int> &b) { return a[0] == b[0] ? a[1] < b[1] : a[0] > b[0]; });
1768
1769 int maxDef = 0;
1770 int count = 0;
1771 for(const auto &p: properties) {
1772 if(p[1] < maxDef) {
1773 count++;
1774 } else {
1775 maxDef = p[1];
1776 }
1777 }
1778 return count;
1779 }

该类的文档由以下文件生成: