CodeDrill
day_streak: --
← 問題一覧に戻る
Python ・ Standard I/O

Problem 19: The Most Frequent Character

A string S is given on one line from standard input. Output, on one line, the character that appears most frequently in S.

If there are multiple characters with the highest frequency, output the one that comes earliest in alphabetical order. For example, in abc, every character appears once, so the answer is a.

Constraints

1 ≤ length of S ≤ 100 (S consists only of lowercase letters)

Input example 1

aabbbcc

Output example 1

b

Input example 2

abc

Output example 2

a

What you'll train

Cover the edge cases

What you get

  • Specify the priority when there is a tie
  • Specify the output format
  • State the range of target characters

How to ask the AI

Clearly tell the AI the priority rule for when there are multiple characters with the highest frequency: choose the one that comes earliest in alphabetical order.

If you ask vaguelyWhen there are multiple most-frequent characters, the AI might select based on some other criterion, such as order of appearance.

あなたのコード

実行しました

プレビュー

AIレビュー(プロンプト練習)

コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。

先にコードを実行し、テストを1つ以上通してください。