5 ms·
Bet you can’t solve this Google interview question
- eesmith 7y agoColor me confused, but isn't this flood fill? https://en.wikipedia.org/wiki/Flood_fill https://en.wikipedia.org/wiki/Flood_fill
- throwaway190504 7y agoI'd be tempted to treat it as a graph and approach it something like: node_colors = get_all_node_colors(G) for color in node_colors: H = prune_nodes_with_color(G, color) for subgraph in H: if node_count(subgraph) > node_count(max_subgraph): max_subgraph = subgraph