online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
class Tree { /* Complete the function to get diameter of a binary tree */ class diaPair { int dia=0; int ht=-1; } diaPair diameter1(Node node) { if(node==null) { return new diaPair(); } diaPair ll=diameter1(node.left); diaPair rr=diameter1(node.right); diaPair obj=new diaPair(); obj.dia=Math.max(ll.ht+rr.ht+2,Math.max(ll.dia, rr.dia)); obj.ht=Math.max(ll.ht,rr.ht)+1; return obj; } int diameter(Node root) { // Your code here return diameter1(root).dia; } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue