This question runs in a pre-configured Salesforce environment - no personal connection required.

Write a method that queries Account records and returns the Name of every Account whose BillingPostalCode starts with a given prefix. Sort the resulting names alphabetically. If the prefix is null or empty, return an empty list. Use a single SOQL query with a LIKE operator to perform the matching.

Examples:

Input: prefix = '9' Output: [List of Account Names where BillingPostalCode begins with 9] Explanation: Returns names of all accounts whose postal code starts with the digit 9, sorted alphabetically Input: prefix = 'ZZZZZ' Output: [] Explanation: No accounts match this prefix Input: prefix = '' Output: [] Explanation: Empty prefix returns an empty list Input: prefix = null Output: [] Explanation: Null prefix returns an empty list
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • This challenge runs without connecting your own org
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay July 2026

Contest runs July 1 - 31. Complete challenges to climb the leaderboard!

Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In