DFS- where and how to use it besides trees and graphs?

Hello, I m new on leetcode and wanted to understand where and how I can use dfs to solve a variety of problem other than trees and graphs. Some examples I have come across that use dfs are Maximum Length of a Concatenated String with Unique Characters problem and Number of Island problem. These problems have nothing to do with trees or graphs. How do I figure out that such problems require a dfs?

Thanks

Comments (0)