I have just started solving Topcoder algorithm problems and have written this algorithm for SRM 466 Div 2 LotteryTicket problem in Java.
As I am not good with time complexity so if somebody could explain me how to calculate time complexity for this algorithm step by step.
public static String buy1(int price,int...b){
int sum=0; String stat="IMPOSSIBLE";
for(int i=0;i<b.length;i++)
sum=sum+b[i];
if(sum==price)
return "POSSIBLE";
if(b.length>1){
stat=buy1(price,Arrays.copyOfRange(b,0,b.length-1));
stat=buy1(price,Arrays.copyOfRange(b,1,b.length));
}
return stat;
}