PIXELBANKv8.2.1
Menu

Character Frequency Counter

Given a string, count the frequency of each character (case-insensitive, ignoring spaces) and return the result as a sorted dictionary.

Example:

  • Input: "Hello World"
  • After lowering and removing spaces: "helloworld"
  • Frequencies: {'d': 1, 'e': 1, 'h': 1, 'l': 3, 'o': 2, 'r': 1, 'w': 1}

Example:

Input:
Hello World
Output:
{'d': 1, 'e': 1, 'h': 1, 'l': 3, 'o': 2, 'r': 1, 'w': 1}
Reasoning:

Step 1: Lowercase and remove spaces "Hello World" → "helloworld"

Step 2: Count each character h:1, e:1, l:3, o:2, w:1, r:1, d:1

Step 3: Sort by key {'d': 1, 'e': 1, 'h': 1, 'l': 3, 'o': 2, 'r': 1, 'w': 1}

Constraints:

  • Input: A single line of text
  • Case-insensitive (convert to lowercase)
  • Ignore spaces
  • Output: Dictionary with characters sorted alphabetically
Editor

Test Results

0/0
Run code to see test results.