Find height of a ternary tree
The expected solution is wrong.

Pick $h=0$. The only ternary heap with height $0$ has only one node. Nevertheless the expected solution says that it needs to have at least $3^0 + 1 = 2$ nodes.

In case you meant to write $3^h \le n \le 3^{h+1}$ instead of $3^h &lt; n &lt; 3^{h+1}$, the expected solution is still wrong.
Consider a ternary heap with $n=2$ nodes. This heap has height $1$ but according the expected solution it should have at least $3^h = 3$ nodes.