Dont know whats wrong with the code. Dont provide the solution just help me make changes to this code itself

public static ArrayList tiling(int n, int m) {
if(n == 0) {
ArrayList br = new ArrayList<>();
br.add(" ");
return br;

	}
	
	ArrayList<String> mr = new ArrayList<>();
	
	if(n < m) {
		
		ArrayList<String> rr = tiling(n-1,m);
		
		for(String rrs:rr) {
			mr.add("V" + rrs );
		}
		
	}
	
	if(n > m ) {
		
		ArrayList<String> rr = tiling(n-1,m);
		for(String rrs:rr) {
			mr.add("V" + rrs );
		}
		
		ArrayList<String> rr1 = tiling(n-m,m);
		for(String rrs:rr1) {
			mr.add("H" + rrs );
		}
		
		
		
	}
	return mr;
}

}

@himanshuep32,
Use DP instead of recursion

i have not reached DP yet

@himanshuep32,
Then you can wait. Because in this question you need to use memoization.

so this question cant be solved by recursion only ?

so this question cant be solved by recursion only ?

@himanshuep32,
With recursion you will get a TLE for large test cases.

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.

i still want to know the recursive solution as i havent reACHED DP yet

clearly Mentioned in this Question, print number of ways . but
You are printing the path.
You will get TLE without DP

Tile placed horizontally(one row is covered now recurse for remaining rows):-
countWays(n - 1, m)

Tile placed vertically if and only if :-
if(n - m >= 0) {
countWays(n - m, m)
}
Now where is the issue, try to visualize the case for 4*3.

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.