CST370: wk 7
This week we went over dynamic programming for collecting coins on a grid and Floyd’s algorithm for finding all-pairs shortest paths. The coin problem was pretty cool because it wasn’t just about getting the max coins, but also figuring out the exact path to take, and having to follow a weird tie-break rule where you pick left over top if they’re equal. Floyd’s algorithm made sense once I thought of it as letting more “stops” into the route one at a time and checking if that made a shorter path. I also got some practice handling -1 as infinity in the input/output. Overall, I feel like I’m getting more comfortable with DP grid problems and shortest path algorithms, and using Scanner in Java made the code way easier to read.
Comments
Post a Comment