ApexSensei

Drills Apex basics

Remove duplicate emails with a Set

A Set<String> keeps each value only once.

Your task

Fill in uniqueEmailCount so it returns how many different emails a list holds, ignoring case and skipping blank entries.

Integer uniqueEmailCount(List<String> emails) {
    return null;
}

List<String> signups = new List<String>{ 'ana@acme.com', 'ANA@acme.com', null, 'raj@acme.com' };
System.debug('Unique signups: ' + uniqueEmailCount(signups));

Requirements

  1. Unique signups: 2 should be printed
  2. uniqueEmailCount with mixed-case emails should be 2
  3. uniqueEmailCount(new List<String>()) should be 0
  4. uniqueEmailCount with null and blank entries should be 2
  5. uniqueEmailCount(...) on a hidden list should be 3
  6. Set<String> should be used
  7. toLowerCase or toUpperCase should be used

Sign in to open this drill