Unable to implement logic for repeated elemnts in array

sort the array after taking input…as we need to output subsets lexicographically
so there could be many approaches to prevent repetition:
1)use a map to store the string printed till now

import java.util.*;
public class coinChangeCombination {


	static HashMap<String,Boolean> map;

	public static void main(String[] args) {
		Scanner obj=new Scanner(System.in);
		int n=obj.nextInt();
		int[] denomination=new int[n];
		for(int i=0;i<denomination.length;i++)
		{
			denomination[i]=obj.nextInt();
		}
		Arrays.sort(denomination);
		int amt=obj.nextInt();

		map=new HashMap<>();
		coinChange(denomination,amt,"",0);
		
	}
	public static void coinChange(int[] denom,int amt,String result,int lastDenomindex)
	{
		if(amt==0)
		{
			if(map.containsKey(result)==false)
				System.out.println(result);
			map.put(result,true);
			return;
		}
			
		for( int i=lastDenomindex;i<denom.length;i++)
		{
			if(amt>=denom[i])
			coinChange(denom,amt-denom[i],result+denom[i]+" ",i+1);
		}
	}

}

another approach could be to prevent redundant calls
HINT:After sorting the array you will have two type of elements:
1)which are equal to there next element
2)which are not equal to there next element

try thinking of the recursive calls you will make for each of these type of elements

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.