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

Query Accounts and assign them to territories based on BillingState, returning a Map where the key is the region name and the value is a List of Account names. The territories are defined as follows: West region includes CA, WA, OR, NV, AZ; Central region includes TX, IL, CO, MO, MN; East region includes NY, FL, MA, PA, NC. Accounts with null or unmapped states should be assigned to the Other territory.

Examples:

Input: No parameters (queries all Accounts)
Output: Map with keys West, Central, East, Other containing Lists of Account names
Explanation: Accounts are grouped by region based on BillingState

Input: Account with BillingState = CA
Output: Account name appears in West region list
Explanation: California is in the West territory

Input: Account with BillingState = null
Output: Account name appears in Other region list
Explanation: Null states go to Other territory

Apex Code Editor

Welcome to Lightning Challenge!

Create an Account

Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.

Create account

How It Works

  • • Write your solution in the code editor
  • • Connect your Salesforce org to test
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Note

You can test your code by connecting to Salesforce, but to save your progress and earn points, you'll need to create an account. Your solutions and achievements will be tracked automatically once you're logged in.