Explanation

584.Count Letters, Digits, Spaces and Other Characters

Easy
Given a string text, return [letters, digits, spaces, others]: how many characters are English letters, how many are digits, how many are spaces, and how many are anything else. Behind the scenes every character is a number — its character codeCharacter Code (ASCII)The number a character is stored as, e.g. 'A' = 65, 'a' = 97, '0' = 48.. Letters and digits occupy consecutive ranges of codes, which is what makes simple range checks work. Built-in tests like isalpha wrap those checks in readable names.

Example 1:

Input: text = "Room 42!"

Output: [4,2,1,1]

Example 2:

Input: text = "abc"

Output: [3,0,0,0]

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ text.length ≤ 200
  • ●text contains printable ASCII characters

text =

Room 42!