can someone please check out my code and tell me where am I wrong coz I have checked the sample input and its working…though I m getting wrong answer…
/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner input = new Scanner(System.in);
int n = input.nextInt();
for(int i = 0; i < n; i++){
int x = input.nextInt();
input.nextLine();
String[] list = new String[x];
for(int j = 0; j < list.length; j++){
list[j] = input.nextLine();
}
int total_time = getTime(list);
System.out.println(total_time);
}
}
public static int getTime(String[] list){
double rv = 0;
double[] time = new double[list.length];
//get the time to type each String
for(int i = 0; i < list.length; i++){
time[i] = 0.2;
String val = list[i];
for(int j = 1; j < val.length(); j++){
if(val.charAt(j) == 'd' || val.charAt(j) == 'f'){
if(val.charAt(j-1) == 'd' || val.charAt(j-1) == 'f'){
time[i] += 0.4;
}
else{
time[i] += 0.2;
}
}
else{
if(val.charAt(j-1) == 'j' || val.charAt(j-1) == 'k'){
time[i] += 0.4;
}
else{
time[i] += 0.2;
}
}
}
for(int k = 0; k < i; k++){
if(list[i].equals(list[k])){
time[i] = time[i] / 2;
}
}
}
for(double itime : time){
rv += itime;
}
rv *= 10;
return (int)rv;
}
}