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.
- Prepare
- Algorithms
- Implementation
- Cavity Map
- Discussions
Cavity Map
Cavity Map
Sort by
recency
|
851 Discussions
|
Please Login in order to post a comment
Here is my c++ solution, you can watch the explanation here : https://youtu.be/BweZoGPs08M
A solution in C# that is more slightly more optimized than the rest I've seen here. Because of how a cavity is defined in this, there are two conditions where you can skip evaluating the four adjacent locations:
[i - 1] [j]
check first, as that will always be false if the cell at that position was changed to 'X'. (Note: not all languages use short-circuit evaluation, so for some languages this will change nothing)Combined, these two changes can remove up to approximately
3.5 * ((N - 2) ^ 2) / 2
comparison operations from our execution time!Java clean solutaion
SWIFT