# can someone tell where i am doing the silly mistake?

Heres the question

Here is my solution

`````` import java.io.*;
import java.lang.*;
import java.util.*;

import javax.net.ssl.ExtendedSSLSession;

class universe
{
public static void main(String args[])throws IOException
{
for(int j=0;j<T;j++)
{
int N= Integer.parseInt(st[0]);
int[]s=new int[N];
for(int i=0;i<N;i++)
s[i]=Integer.parseInt(sb[i]);
if(N==1 && st[1]=="Dee" && (s[0]%2)==0)
System.out.println("Dee");
else
System.out.println("Dum");
}
}
}
``````

Your logic is incorrect. According to your code, for all the values of n other than 1, the output will be Dum only. This is not correct. For instance, the following cases will give wrong answer with your code.

2 Dee
1 1 Output: Dee

2 Dum
1 1 Output: Dee

1 Like

Sir, you’re not even going through the array

``````             if(N==1 && st[1]=="Dee" && (s[0]%2)==0)
``````

Look at this part

``````               s[0]%2
``````

Why only the first element? You should be going through the whole array. You should have a for loop to go through the array and check who will win in the end

@therisingsun

sir, one person at a time can pick up only from a single heap, and in both your test cases, dee(even person) cant pick up any element from any heap, so its sure to loose.
but my problem is not that, actualy the problem even if the condition

’ [if(N==1 && st[1]==“Dee” && (s[0]%2)==0)]

is satisfied, its printing dum and not “dee”? i am not able to understand why?

@kunnu120
if(N==1 && st[1]==“Dee” && (s[0]%2)==0)
is satisfied, even then program is printing “dum” and not “dee” ?

You are saying that even if the condition is satisfied , its not printing “dee”. This is because your condition never gets satisfied.
You are using st[1]==“Dee”. Here ‘==’ indicates equating the addresses of st[1] and string literal “Dee”, and their addresses are different. Try using equals() method. This method equates the value.

1 Like

Let’ say we have input

1
3 Dee
2 3 2

The right answer will be Dee as for the first try Dee will eat the first even number (which is a[0] =2) and then it’s time for Dum, he will eat the maximum number of odd stones, so he can win. So, now he will eat those 3 stones(which is a[1]=3) and now it’s time for Dee he will eat the even number of stones. which is (a[2]=2). So, the winner should be Dee but your answer printing Dum. You’re saying that if N is not equal to 1 then Dum will always win. And for the string compare, to check if strings are equal, you should be doing NameOfTheString.equals(“theNameYouAreComparingWith”). Try using a for loop so you can play with every element of the integer. I will not tell you the solution, as I can see you’re a good coder, but you’re overcomplicating things as I find Buffereader tough to start with you’re taking the input in a very complicated way.

You could have

public static void main(String[] args)

{

``````public class universe
``````

{

``````  Scanner input = new Scanner(System.in);

int T = input.nextInt();

for(int i = 0;i<T;i++)
``````

{

``````   int sizeOfTheArray = input.nextInt();

int[] array = new int[sizeOfTheArray);

String name = input.nextLine();

for(int k = 0; k<sizeOfTheArray;k++)

{

array[k] = input.nextInt();

}
``````

If you still have problem, please ask!! Just don’t over-complicate this question

//