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

#include <leetcode.h>

静态 Public 成员函数

static bool PredictTheWinner (vector< int > &nums)
 

详细描述

在文件 leetcode.h3110 行定义.

成员函数说明

◆ PredictTheWinner()

bool leetcode::predict_the_winner::Solution::PredictTheWinner ( vector< int > &  nums)
static

在文件 leetcode.cpp8825 行定义.

8825 {
8826 const int length = nums.size();
8827 auto dp = vector<int>(length);
8828 for(int i = 0; i < length; i++) {
8829 dp[i] = nums[i];
8830 }
8831 for(int i = length - 2; i >= 0; i--) {
8832 for(int j = i + 1; j < length; j++) {
8833 dp[j] = max(nums[i] - dp[j], nums[j] - dp[j - 1]);
8834 }
8835 }
8836 return dp[length - 1] >= 0;
8837 }

被这些函数引用 leetcode::predict_the_winner::TEST().


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