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

#include <leetcode.h>

静态 Public 成员函数

static bool winnerOfGame (string colors)
 

详细描述

在文件 leetcode.h1883 行定义.

成员函数说明

◆ winnerOfGame()

bool leetcode::remove_colored_pieces_if_both_neighbors_are_the_same_color::Solution::winnerOfGame ( string  colors)
static

在文件 leetcode.cpp4929 行定义.

4929 {
4930 int a_count = 0;
4931 int b_count = 0;
4932 vector vec(colors.length(), true);
4933 vec[0] = false;
4934 vec[colors.length() - 1] = false;
4935 for(int i = 0; i + 1 < colors.length(); i++) {
4936 if(colors[i] != colors[i + 1]) {
4937 vec[i] = false;
4938 vec[i + 1] = false;
4939 }
4940 }
4941 for(int i = 0; i + 1 < colors.length(); i++) {
4942 if(vec[i]) {
4943 if(colors[i] == 'A') {
4944 a_count++;
4945 } else {
4946 b_count++;
4947 }
4948 }
4949 }
4950 return a_count > b_count;
4951 }
int vec[100010]
Definition: pat.cpp:5095

引用了 pat::a::a7_2::vec.

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


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