Expand description
§Treetop Tree House
Part 1 is solved with an efficient O(n)
algorithm. Part 2 is also solved with an efficient O(n)
algorithm, using a bit manipulation trick to make the complexity independent of the number of digits.
Constants§
Functions§
- Convert a 2D grid of ASCII digits into a 1D
vec
of heights. - Calculate visible trees using a rolling maximum for each row and column in left, right, up and down directions.
- Calculate the distance visible in each direction by using 10 rolling maximum values for each height packed into a single
u64
.
Type Aliases§
- Input 🔒