Refactor almost everything

This commit is contained in:
Arkaprabha Chakraborty
2022-08-02 12:21:43 +05:30
parent ccc376aea0
commit cab1180397
39 changed files with 117 additions and 54 deletions

View File

@@ -9,11 +9,11 @@ struct TreeNode {
};
class Solution {
private:
void maxDepth(TreeNode *root, int index, int *max) {
private:
void maxDepth(TreeNode *root, int index, int &max) {
if (root == nullptr) {
if (index > *max) {
*max = index;
if (index > max) {
max = index;
}
return;
@@ -23,10 +23,10 @@ class Solution {
}
}
public:
public:
int maxDepth(TreeNode *root) {
int max = 0;
maxDepth(root, 0, &max);
maxDepth(root, 0, max);
return max;
}