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

Given a list of user IDs, fetch each user from the DummyJSON API and build a map of user first names to their city. The API endpoint is https://dummyjson.com/users/{id} and the response includes a "firstName" field at the top level and an "address" object containing a "city" field. Return an empty map for null or empty input. If a request fails, skip that user and continue with the next one.

The DummyJSON user response structure:

{
  "id": 1,
  "firstName": "Emily",
  "address": {
    "city": "Phoenix"
  }
}

Examples:

Input: userIds = (1) Output: {Emily=Phoenix} Explanation: User 1 has firstName Emily and lives in Phoenix Input: userIds = (1, 2) Output: {Emily=Phoenix, Michael=Anytown} Explanation: Two users fetched and mapped Input: userIds = null Output: {} Explanation: Null input returns empty map Input: userIds = () Output: {} Explanation: Empty list returns empty map
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

Contest Alert

🏆 All Time Leaderboard

Contest runs January 1, 1970 - December 31, 9999. Complete challenges to climb the leaderboard!

Points are calculated for challenges completed during the contest period.