Skip to content

Most frequent character · ⁨出现最多的字符⁩

English

Most frequent character

Return the character that appears most often in a non-empty String. If two characters tie, return the one that appears earliest. A simple approach: for each character, count how many times it occurs, and keep the best so far — using a strict > so a tie keeps the earlier character.

中文

出现最多的字符

返回非空 String 中出现次数最多的字符。如果两个字符并列,返回最先出现的那个。一个简单的做法:对每个字符,数出它出现的次数,并保留目前最优的 —— 用严格的 >,这样并列时保留较早的那个字符。

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩