Skip to content

Commit 3eece70

Browse files
authored
Merge pull request neetcode-gh#1473 from MHamiid/patch-9
Remove unnecessary variable in 543-Diameter-Of-Binary-Tree.c
2 parents 04a3ee6 + fc50551 commit 3eece70

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

c/543-Diameter-Of-Binary-Tree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ int recur(struct TreeNode* root, int* maxDiameter) {
2525
}
2626

2727
int diameterOfBinaryTree(struct TreeNode* root) {
28-
int * maxDiameter;
29-
int result = 0;
30-
maxDiameter = &result;
31-
recur(root, maxDiameter);
32-
return result;
28+
int maxDiameter = 0;
29+
30+
recur(root, &maxDiameter);
31+
32+
return maxDiameter;
3333
}

0 commit comments

Comments
 (0)