@thoughtfulmongoose This is a very interesting question!! I don't believe there is a really good way to solve it backwards, unfortunately.

For example, if you wanted to work backwards using the Breadth-First search, there are a bunch of different starting cases. You could have 05, 15, 25, 35. Focusing only on 05, there are also a bunch of different possibilities that lead to it! For example: 15, 25, 35, or even 14, 23, 32 (combine the water to make 5 gallons). So, in essence, you 1) do not have a fixed "end point" of the tree, and 2) each end point of the tree branches backwards into a bunch of different possibilities.

It is probably technically possible to solve backwards through brute force, but this doesn't necessarily mean it's easiest/most methodical (which is usually valuable when it comes to math/math competitions). Specifically, by solving "forwards," you have only one starting point 00. Also, it is easier to see the different options available to you next, because you can either fill up buckets or move the water around.

tl;dr - it may be possible to work backwards, but I don't think it is the best, most efficient way 😄 great question though!