codementor on Nostr: Question: A binary tree is balanced if, at every node, the heights of the left and ...
Question: A binary tree is balanced if, at every node, the heights of the left and right subtrees differ by at most 1.
Write a check that visits each node only once.
(CtCI 4.4)
Try to answer before you open the reply.
#tg004 · TG-004-Q1
Published at
2026-10-25 15:08:09 UTCEvent JSON
{
"id": "77b0d1d96ecef54c4b5e42b9572f7c895c7eed3730a5bbb5f279632ba2bb88c6",
"pubkey": "e68a0856e90d9997b1f721e905249896412dd570399a987b2e8fd5e7fcfe2279",
"created_at": 1792940889,
"kind": 1,
"tags": [
[
"t",
"tg004"
]
],
"content": "Question: A binary tree is balanced if, at every node, the heights of the left and right subtrees differ by at most 1.\n\nWrite a check that visits each node only once.\n\n(CtCI 4.4)\n\nTry to answer before you open the reply.\n\n#tg004 · TG-004-Q1",
"sig": "231e008511a81d579284d746151e7dee6943510f81f5911cff56a42c250e58722b273c345cda3138108449e50750a528e53ff585aedd7486abd2d679f5062be5"
}