🥵 Hot. Torturous. Today’s run was the hardest I’ve endured in some time, though it was my standard route.
🌡️ I guess temperature makes a big difference. Today’s high is 79 degrees Fahrenheit.
🤷 That probably means I’m spoiled with cool weather. Oh well.
I previously did some isolated planning for this problem.
Let’s see how well that planning helps with implementation today.
🪞 Reflections
Reading my previous planning notes & writing out a concrete plan took < 6 minutes
My plan worked
If I subtract the previous 11:44 from total time, this took 28:06
It’s a medium problem, so that’s probably acceptable, as I don’t think I’ll get 2 mediums in a single interview
I’m happy that my plan worked out as expected
I don’t care too much about the 1 error that was caught at execution time. I don’t think an interviewer will care about the parens needed for a negative next to an exponent.
Then again, I guess it is mathematically ambiguous without parens, because (-x)^y does not necessarily equal -(x^y)
I used, perhaps more caution than was warranted by creating similar constants for, e.g. the number of digits in the extreme value
This caution was due to not knowing the exact value of the numbers and not wanting to hastily make a potentially invalid assumption
But it did make the code a bit more complex
I’d like to come back and clean the problem up to remove unnecessary complexity
Given the root of a binary tree, return the length of the diameter of the tree.
The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
The length of a path between two nodes is represented by the number of edges between them.
🪞 Reflections
This is labeled an easy problem, but it seemed… not super easy
The bug was a weird one, related to the execution model used by LeetCode
On one hand, that’s what I get for doing unsafe things
On the other hand, in an interview this probably would have been fine
On the third hand, I guess I should start practicing currying state into a parameter to systematically avoid global state in recursive functions
The time to implement up to the weird state bug was acceptable - 16:25
Another tree problem that’s not super easy. I should definitely keep practicing on trees.
Before we can understand the purpose of a system, we must understand the larger system it is a part of. From an understanding of the purpose of the larger whole, we can derive a purpose of the part.
Then, we can use analysis to decompose our system into parts.
Practical implications
Who will build the system?
Single owner: Individual → large, hierarchical corporation