InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Prime Subarrays

You are given an integer array A of size N.

You have to find the number of subarrays those have Prime Sum.

Input Format

The first argument given is an Array A, having N integers.

Output Format

Return an Integer, i.e number of subarrays those have prime sum.


1 <= N <= 1e3
1 <= A[i] <= 1e3

For Example

    A = [1, 2, 3]
    no. subarray      sum
    1.  [1]			  1
    2.  [1, 2]		  3
    3.  [1, 2, 3]     6
    4.  [2]		      2
    5.  [2, 3]		  5
    6.  [3]		      3

	here we have 4 subarrays(2, 4, 5, 6) those have prime sum. 
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Prime Subarrays on Interview Code Editor
Sign Up
to access hints and editorial solutions for Prime Subarrays


Click here to start solving coding interview questions