Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    3115 - Maximum Prime Difference\.

    Medium

    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.

    Example 1:

    Input: nums = 4,2,9,5,3

    Output: 3

    Explanation: nums[1], nums[3], and nums[4] are prime. So the answer is |4 - 1| = 3.

    Example 2:

    Input: nums = 4,8,2,8

    Output: 0

    Explanation: nums[2] is prime. Because there is just one prime number, the answer is |2 - 2| = 0.

    Constraints:

    • <code>1 <= nums.length <= 3 * 10<sup>5</sup></code>

    • 1 &lt;= nums[i] &lt;= 100

    • The input is generated such that the number of prime numbers in the nums is at least one.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer maximumPrimeDifference(IntArray nums)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait