Can you give some more test cases?

Like for 36 what would be the answer?

Like if 18 is given it will be broken into 9,6,4? I want to ask 18/4 will be valid here?

What is the error in my code?

When I am using Top DOwn or Bottom Up, it is giving run error

Hey @ap8730390
Constraints is too big

0 <= n <= 1 000 000 000
use HashMap instead of Array

static HashMap<Integer, Long> map = new HashMap<Integer, Long>();

public static long exchange(int n) {
	if (n == 0) {
		return 0;
	}

	if (map.containsKey(n)) {
		return map.get(n);
	}

	map.put(n, Math.max(n, exchange(n / 2) + exchange(n / 3) + exchange(n / 4)));
	return map.get(n);

}

Yeah , it showed out of heap space. So whenever constraints are big, we should use hashmap???

Was my code alright then???

Q whenever constraints are big, we should use hashmap???
yes
Q Was my code alright then???
yes

I had one more doubt to ask

when i was running this code I was getting an error

How do I tackle these types of error?

I know typecasting can help but inside arr[here…] it requires int
and I want to put long here

for(long i=12; i<=n; i++){
I should be an integer . becuzz Arrays Ka indexing long data Type se nhi hota h
got it ??

Haan but iss question ke case mei i could go upto long… tab kya karein?

Koi tareeka hai jisse long type ke index array mei access kar sake?

@ap8730390 in this situation Use HashMap

Q Koi tareeka hai jisse long type ke index array mei access kar sake?
Answer Nope

And arraylist ke saath bhi same case hoga?

Arraylist al = new ArrayList<>();
al.get(i);// then i should also be of type int or it can be long?