Skip to content

Commit 414d5d0

Browse files
Larger value in Each level of BST (#134)
* cpp folder in cpp * comiti * as * Largestvalue in each level BST * Largest value in each level of BST * large Value in each level BST
1 parent 4b200d6 commit 414d5d0

6 files changed

+44
-9
lines changed

Diff for: .vscode/settings.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"files.associations": {
3+
"deque": "cpp",
4+
"vector": "cpp",
5+
"xstring": "cpp"
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
class Solution {
22
public:
33
int sum(int num1, int num2) {
4-
return num1 + num2;
5-
4+
return num1 + num2;
65
}
76
};

Diff for: C++/largest-rectangle-in-histogram.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Name: Sumit Chakraborty
22

33
// Username: chakraborty9569
4-
4+
#include<vector>
5+
#include<stack>
56
class Solution {
67
public:
78
int largestRectangleArea(vector<int>& heights) {

Diff for: C++/largevaluesineachlevelbst.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*Finding largest value in each level of a BST*/
2+
3+
class Solution{
4+
public:
5+
vector<int>largestvalueineachlevel(TreeNode*root){
6+
if(root == NULL)
7+
return {};
8+
vector<int>max_vals;
9+
int size;
10+
int max;
11+
TreeNode*temp;
12+
queue<TreeNode*>q;
13+
q.push(root);
14+
while(!q.empty()){
15+
size = q.size();
16+
max = INT_MIN;
17+
while(size--){
18+
temp = q.front();
19+
q.pop();
20+
max = max(max, temp->val);
21+
if(temp->left)
22+
q.push(temp->left);
23+
if(temp->right){
24+
q.push(temp->right);
25+
}
26+
max_vals.push_back(max);
27+
}
28+
}
29+
return max_vals;
30+
31+
}
32+
33+
};

Diff for: Python/129.SumRootToLeafNumber.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
# Definition for a binary tree node.
2-
# class TreeNode:
3-
# def __init__(self, val=0, left=None, right=None):
4-
# self.val = val
5-
# self.left = left
6-
# self.right = right
1+
72
class Solution:
83
def sumNumbers(self, root: Optional[TreeNode]) -> int:
94
def dfs(node, current):

Diff for: Python/threesum.py

Whitespace-only changes.

0 commit comments

Comments
 (0)