There are two recursive functions  depth_max and isBalanced :)
G
gpraveenkumar
@gpraveenkumar
97
Reputation
47
Posts
217
Profile views
1
Followers
0
Following
Posts made by gpraveenkumar

RE: C++ with one recursive function, accepted

RE: 3 different ideas: XOR, SUM, Binary Search. Java code
Sorry, I modified my answer. Your code is perfect :)

RE: Can't see where I got wrong.
Problem caused due to
if (root>left) root>left>next = root>right;
You are assuming that if root has a left node, it should have a right node. Incorrect, can cause Runtime Errors. But you are doing that check in this line for the rest of the program :)
TreeLinkNode *p = root>right ? root>right : root>left;

RE: Simple Java solution, time  O(n), space  O(1). Just get the difference in sizes and iterate.
My comment was meant for a different post.... You code is perfect... I am sorry!

RE: [Java] My AC Solution: Sum up and minus the differences
I am surprised that the Judge is accepting OP's solution. The OP's code would fail for a simple test cases like this:
// When both a,b are at 1 .... ca=cb and ta=tb, code returns 1 headA : 1 > 3 > 2 > NULL headB : 1 > 2 > 3 > NULL // When both a,b are at 1 .... ca=cb and ta=tb, code returns 1 headA : 1 > 3 > 3 > NULL headB : 1 > 2 > 4 > NULL // When both a,b are at 1 .... ca=cb and ta=tb, code returns 1 headA : 5 > 6 > 1 > 3 > 2 > NULL headB : 6 > 5 > 1 > 2 > 3 > NULL

RE: This problem has a O(n) solution?
Set insertion and deletion can take 'O(n)' in the worst case making the time complexity of you algorithm 'O(n^2)'.