<p>You are given an integer array <code>nums</code>.</p>

<p>Return an integer that is the <strong>maximum</strong> distance between the <strong>indices</strong> of two (not necessarily different) prime numbers in <code>nums</code><em>.</em></p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [4,2,9,5,3]</span></p>

<p><strong>Output:</strong> <span class="example-io">3</span></p>

<p><strong>Explanation:</strong> <code>nums[1]</code>, <code>nums[3]</code>, and <code>nums[4]</code> are prime. So the answer is <code>|4 - 1| = 3</code>.</p>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [4,8,2,8]</span></p>

<p><strong>Output:</strong> <span class="example-io">0</span></p>

<p><strong>Explanation:</strong> <code>nums[2]</code> is prime. Because there is just one prime number, the answer is <code>|2 - 2| = 0</code>.</p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 3 * 10<sup>5</sup></code></li>
	<li><code>1 &lt;= nums[i] &lt;= 100</code></li>
	<li>The input is generated such that the number of prime numbers in the <code>nums</code> is at least one.</li>
</ul>

import math
class Solution:
    def __init__(self):
        self.arr = []
    def seive(self,n):
        arr= [True for i in range(n+1)]
        arr[0],arr[1] = False,False
        for i in range(2,int(math.sqrt(n)) + 1):
            if arr[i] == True:
                j = i * i 
                while j<=n:
                    arr[j] = False
                    j+=i
        return arr
    def isprime(self,number):
        return self.arr[number]
    def maximumPrimeDifference(self, nums: List[int]) -> int:
        self.arr = self.seive(1001)
        max_diff = 0
        min_ind = -1
        n = len(nums)
        for i in range(n):
            value = nums[i]
            if self.isprime(value):
                if min_ind == -1:
                    min_ind = i
                else:
                    diff = abs(min_ind- i)
                    max_diff = max(max_diff,diff)
        return max_diff
820