Compiler is not processing code please check the code of subset sum problem of recursion

public class Main {

public static ArrayList<Integer> subset(int arr[],int ci,int n)
{

	if(c1==n)
   {	
    ArrayList<Integer> base = new ArrayList<Integer>();
	base.add(0);
	return base;
    }
	int first = a[ci];
	ArrayList<Integer> result = new ArrayList<Integer>();
	ArrayList<Integer> sol = new ArrayList<Integer>();
	result = subset(arr,ci+1);
	for(int e:result){
	sol = e;
	sol = first + e;
	}
	return sol;
}
public static void main(String args[]) {
ArrayList<Integer> output = new ArrayList<Integer>();
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int n = sc.nextInt();
int arr = new int[n];
for(int i=0;i<n;i++)
{
    arr[i] = sc.nextInt();
}

for(int i=0;i<t;i++)
{
	output = subset(arr,0,n);
    output.remove(0);
	if(output.contains(0))
	System.out.println("YES");
	else
	System.out.println("NO");
}

}

@affanahmed,
I have corrected your code for compiler errors: https://ide.codingblocks.com/s/195083
But there are logical errors present. Please correct them.

package testrecursion;[quote=“affanahmed, post:1, topic:32394, full:true”]
public class Main {

public static ArrayList<Integer> subset(int arr[],int ci,int n)
{

	if(c1==n)
   {	
    ArrayList<Integer> base = new ArrayList<Integer>();
	base.add(0);
	return base;
    }
	int first = a[ci];
	ArrayList<Integer> result = new ArrayList<Integer>();
	ArrayList<Integer> sol = new ArrayList<Integer>();
	result = subset(arr,ci+1);
	for(int e:result){
	sol = e;
	sol = first + e;
	}
	return sol;
}
public static void main(String args[]) {
ArrayList<Integer> output = new ArrayList<Integer>();
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int n = sc.nextInt();
int arr = new int[n];
for(int i=0;i<n;i++)
{
    arr[i] = sc.nextInt();
}

for(int i=0;i<t;i++)
{
	output = subset(arr,0,n);
    output.remove(0);
	if(output.contains(0))
	System.out.println("YES");
	else
	System.out.println("NO");
}

}
[/quote]

i tried this code in eclipse fine but your suggestions for logical improvement will help a lot.

import java.util.ArrayList;
import java.util.Scanner;

public class Subsetsum {
public static ArrayList subset(int arr[],int ci,int n)
{

		if(ci==n)
	   {	
	    ArrayList<Integer> base = new ArrayList<Integer>();
		base.add(0);
		return base;
	    }
		int first = arr[ci];
		ArrayList<Integer> result = new ArrayList<Integer>();
		ArrayList<Integer> sol = new ArrayList<Integer>();
		result = subset(arr,ci+1,n);
		for(int e:result) {
		sol.add(e);
		sol.add(first + e);
		}
		
		return sol;
	}
    
    public static void main(String args[])
    {
    	ArrayList<Integer> output = new ArrayList<Integer>();
    	Scanner sc = new Scanner(System.in);
    	int t = sc.nextInt();
    	

    	for(int i=0;i<t;i++)
    	{
                      int n = sc.nextInt();
    	         int[] arr = new int[n];
    	
    		for(int j=0;j<n;j++)
        	{
        	    arr[j] = sc.nextInt();
        	}
    		output = subset(arr,0,n);
    	    output.remove(0);
    		if(output.contains(0))
    		System.out.println("YES");
    		else
    		System.out.println("NO");
    	}    	
    }

}

@affanahmed,
Your code was correct: https://ide.codingblocks.com/s/195458
Instead of:

System.out.println("YES");
else
System.out.println("NO");

You have to print:

			System.out.println("Yes");
		else
			System.out.println("No");

Rest the entire code is correct.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.