You are viewing a single comment's thread. Return to all comments →
The problem is not hard at all, but very poor description and badly structured input make it a lot harder than it should be. I would suggest some areas for clarification. Is i the line number? Or is it node index? It's actually both, and the right answer is that null node should not be indexed but line numbers go on. It's not immediately clear if K is applied to depth or height, because below for some reason letter h is used to represent the depth. Use of index in the input and other constrains literally enforce the use of array upon the user.