LeetCode Biweekly Contest 63 2問目 - Remove Colored Pieces if Both Neighbors are the Same Color [2038]

Source

LeetCode Biweekly Contest 63
問題文

問題概要

省略

解法

省略

cLay(version 20210926-1)のコード

C++に変換後のコードはこちら

#define main dummy_main
{}
#undef main

class Solution {
public:
  bool winnerOfGame(string A) {
    int res = 0;
    rep(i,1,A.size()-1){
      if(A[i-1] == A[i] == A[i+1] == 'A') res++;
      if(A[i-1] == A[i] == A[i+1] == 'B') res--;
    }
    return res > 0;
  }
};

Current time: 2024年04月25日12時50分19秒
Last modified: 2021年10月24日03時23分34秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る

Logged in as: unknown user (not login)

ログイン: