Some More Homework - Wrong Answer

For the problem Some More Homework, Why am I getting wrong answer? I have implemented in Java. Here is the code:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class SomeMoreHomework
{
	public static void main(String args[]) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t=Integer.parseInt(br.readLine());
		if(t > 10)
		{
			System.out.println("Number of testcases exceeded");
		}
		else
		{
			for(int j=0;j<t;j++){
			int p = Integer.parseInt(br.readLine());
			String c = br.readLine().replaceAll(" ",""); 
			String b = "0110100110010110";
			String result = "";
			while(p > b.length())
			{
				b += b;
			}
	
			for(int i=1;i<p;i++) 
			{
				result += b.indexOf(c.substring(0,i))+" ";
			}
			result += b.indexOf(p);
			System.out.println(result);
			}
		}
	}
}

Hey, using replace… methods you are changing
-1
to

  • 1 (space should not be there between ‘-’ and ‘1’)

12 to 1 2 . i.e you are splitting every thing ,this is wrong.
Still if you have doubt try this case:

1

13

1 0 1 1 1 0 1 0 1 0 0 1 1

Correct answer: 1 2 2 11 -1 -1 -1 -1 -1 -1 -1 -1 -1

Your answer : 1 2 2 1 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1

I edited my code accordingly, but again if I submit, I get wrong answer. Please have a look

//