I concur with everything here but I would say find a solution to your problem plus a little bit more. In particular, try to find out about where the boundaries of the problem are such that this solution wouldn’t work anymore. Maybe it stops working at a certain scale, or with less behaved input, or if you need to support Chinese characters. This helps me really understand the solution, and not feel like I just have a book of incantations.