Minimum money needed --see the code wrong output ,might be rec call is wrong correct the code

import java.util.Scanner;

public class Minimum_Money_Needed {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int weight = sc.nextInt();
	int price[] = new int[weight];
	for (int i = 0; i < price.length; i++) {
		price[i] = sc.nextInt();
	}
	System.out.println(Min_Money(price, 0, weight));
}

public static int Min_Money(int[] prices, int i, int weight) {
	if (weight == 0) {
		return 0;
	}
	if(i == prices.length) {
		return 0;
	}
	int inc = 0;
	if (weight >= i+1) {
		inc = Min_Money(prices, i, weight - (i+1))+  prices[i];
	}
	int exc = Min_Money(prices, i + 1, weight);
	return Math.min(inc, exc);
}

}

@arpitranjan641_d2edeaf633b10b54 bench mark your code with my code :

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.