Help us understand the problem. What is going on with this article?

# 最長AB列を求める

More than 1 year has passed since last update.

# 最長AB列を求める

Sに含まれる連続した区間で'A'と'B'の数が等しいものの最長の長さを答えよ。

# ソースコード

```<?php
//入力値
\$nyu = "ABBBAAAAA";
//評価する値(それぞれの区切った値を配列に格納)
\$hyo1 = "A";
\$hyo2 = "B";
\$arrray1=explode(\$hyo1, \$nyu);
\$arrray2=explode(\$hyo2, \$nyu);

//A、B配列の数分だけ、レングスを格納する
for(\$i = 0; \$i < count(\$arrray1); \$i++){
\$arr1_len[\$i] = strlen(\$arrray1[\$i]);
}
for(\$i = 0; \$i < count(\$arrray2); \$i++){
\$arr2_len[\$i] = strlen(\$arrray2[\$i]);
}

//取得した配列のmax値を取得
\$arr1_max = max(\$arr1_len);
\$arr2_max = max(\$arr2_len);
//A,B双方で取得したmax値の低いほうを取得
\$arr_min = min(\$arr1_max,\$arr2_max);

//結果値
\$kekka = \$arr_min * 2;
print(\$kekka);

?>
```

Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away