Practice Maximum Prime Difference
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an integer array nums. Return an integer that is the maximum distance between the indices of two (not necessarily different) prime numbers in nums.
Source: Maximum Prime Difference on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [4,2,9,5,3]
Output
3
# Example 2
Input
nums = [4,8,2,8]
Output
0
Constraints
1 <= nums.length <= 3 * 10^5
1 <= nums[i] <= 100
The input is generated such that the number of prime numbers in the nums is at least one.
Related LeetCode Problems
Practice more problems similar to Maximum Prime Difference.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.