This question runs in a pre-configured Salesforce environment - no personal connection required.
Analyze Star Wars films by retrieving character count data from the Star Wars API. Accept a film ID and return the number of characters that appear in that specific film.
Use the Star Wars API endpoint https://swapi.info/api/films/{id} to get film data and count the characters in the characters array. Handle error cases appropriately (invalid film IDs, API failures, etc.) by returning -1.
Valid film IDs are 1-6, corresponding to A New Hope, The Empire Strikes Back, Return of the Jedi, The Phantom Menace, Attack of the Clones, and Revenge of the Sith.
Examples:
Input: filmId = 1
Output: 18
Explanation: A New Hope has 18 characters
Input: filmId = 4
Output: 34
Explanation: The Phantom Menace has 34 characters
Input: filmId = 0
Output: -1
Explanation: Invalid film ID, return -1
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
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.