Diameter of binary tree

my code give wrong diameter value

sahi to araha h
5 2 3 -1 -1 -1 6 -1 -1
image
answer is 3
ur answer is also 3

Yup but height comes wrong

5 2 3 4 -1 -1 -1 -1 6 -1 -1
sahi arahi hheight bhi

iski height 4 h
4 he arahi h