r/javahelp • • Jul 16 '19

Can every dp problem be solved top down and bottom up?

Title

2 Upvotes

4 comments sorted by

3

u/ynvaser That Java Guy Jul 16 '19

Did you pass your test, or are you still writing it?

1

u/osdir202 Jul 16 '19

i have passed it but only the bottom up approach makes sense for me. The question is longest increasing in array so for [2, 9, 10, 3, 4, 5 ,6] this would be 5 -> 2, 3, 4, 5 , 6. My solution was O(n^2) bottom up with two nested for loops.

1

u/Python4fun Jul 16 '19

Big problems need a top down approach, and then the smaller problems can be solved bottom up.

Facebook needed a top down look to figure out what parts were needed (iterate as needed) as they couldn't just start piecing together sets of data and then figure out how to use them.

1

u/e_falk Extreme Brewer Jul 16 '19

This isn't really Java related