Sort 581 Discussions, By:
Please Login in order to post a comment
One of the most ambiguous question on HackerRank. I wish I could down vote the problem description.
In python had to change recursion limit to work on the last two test inputs
Solved the problem but had to.
1. Create node object.
2. Create a breathFirst to read input.
3. Create a depthFirst to change height.
4. Create a Inorder to print.
Took 3 hours total. Is is listed as "Easy?" Is there an easier way than the apporche I did?
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.
I usually agree with Hackerrank's difficulty ratings, however I feel given how tedious this problem is, it should be a "Moderate" at least