-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from bastenahamad/main
Added Solution of POTD of July 1
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Solution { | ||
public: | ||
TreeNode *rec(vector<int>&ar, int i) { | ||
if(i >= ar.size()) return NULL; | ||
TreeNode *root = new TreeNode(ar[i]); | ||
root->left = rec(ar, 2*i+1); | ||
root->right = rec(ar, 2*i+2); | ||
return root; | ||
} | ||
void convert(Node *head, TreeNode *&root) { | ||
Node *temp = head; | ||
vector<int>cur; | ||
while(temp != NULL) { | ||
cur.push_back(temp->data); | ||
temp = temp->next; | ||
} | ||
root = rec(cur, 0); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
### Please add solutions of July 2024 | ||
### Please Add POTDs of GFG JULY Month |