We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Ema's Supercomputer
Ema's Supercomputer
Sort by
recency
|
307 Discussions
|
Please Login in order to post a comment
def twoPluses(grid):
Python3 solution:
swift its long but solve all the test cases
Haskell
I started out thinking I could simply go through each good cell and compute the biggest plus I could make with that cell as its center. While doing this, I tracked the largest two areas seen, then finally returned the product of those two values.
This doesn't work for two reasons:
The second case might happen if you have a 9-area plus and a 13-area plus that overlap. But inside the 13-area plus is a smaller 9-area plus that doesn't overlap with the other 9-area plus. Those two pluses might turn out to be the two largest ones in the grid.
So the approach looks more like this:
pluses
array to hold all of the pluses you find.pluses
.len(set1 & set2) > 0
.) If they don't overlap, update the maximum product found so far.