My issue
i want solution i tried many times please provide me accurate solution
My code
import java.util.*;
import java.text.DecimalFormat;
class Codechef
{
public static void main (String[] args)
{
DecimalFormat decimalFormat = new DecimalFormat("0.0000000000");
Scanner read = new Scanner(System.in);
int t = read.nextInt();
for(int i=0; i<t; i++)
{
ArrayList<Integer> face = new ArrayList<Integer>();
int n = read.nextInt();
int a = read.nextInt();
int b = read.nextInt();
// Update the code below to solve this problem
// ArrayList<Integer> a=new ArrayList<Integer>();
for(int j=0;j<n;j++)
face.add(read.nextInt());
int c1=1;
for(int k=0;k<n-1;k++)
if(face.get(k)==a && face.get(k+1)==b)
c1+=1;
// for(int j=0 , k=n-1; j<=n-1 && k>=1 ;j++,k--)
// System.out.println(j+" "+k);
//System.out.printf("%d\n",(double)(c1*c1)/(n*n));
System.out.println( decimalFormat.format((double)(c1*c1)/(n*n)));
}
}
}
Learning course: Solve Programming problems using Java
Problem Link: CodeChef: Practical coding for everyone