Skip to content
Katabench
Try free

Count Distinct Letters

Easy About 8 min Free, no account needed

How many different letters appear? A 26-slot array already knows.

The brief

Given text, count the distinct English letters present, case-insensitive (the answer is between 0 and 26).

The allocation budget

Lower-casing the whole document (and LINQ chains over it) allocate copies and iterator machinery. The hidden test is a 100 KB document under a 32 KB allocation budget, so watch your allocations: a copy of the document alone blows it.

Starter code

C#
using System;

public class Solution
{
    // TODO: return the number of distinct English letters, case-insensitive.
    public int CountDistinctLetters(string text)
    {
        throw new NotImplementedException();
    }
}

How it is graded

Visible examples help you iterate. Hidden tests then cover edge cases and larger inputs, and every test reports server-measured time and allocated bytes.

C# coding challenges →

What it practices

Hash maps and sets
Trade memory for constant-time lookups, membership tests and frequency counts.
String processing
Parse, scan and match text character by character with correct edge cases.

Related katas