2026 July 18 Problems

42 views
Skip to first unread message

daryl...@gmail.com

unread,
Jul 18, 2026, 1:01:00 PMJul 18
to leetcode-meetup

Feel free to work on any of the problems you want; we'll have people present their solutions at 11:30.

Please post your solutions to this thread so others can use this as a reference.
Feel free to work on any of the problems you want; we'll have people present their solutions at 11:30.

Please post your solutions to this thread so others can use this as a reference.


998. Maximum Binary Tree II Medium 70.7%

Hard problem has been carried over from last week



Here is the meeting url:

Full details:

Topic: Leet Code meeting
Time: Mar 28, 2026 10:00 AM Pacific Time (US and Canada)
        Every week on Sat, 110 occurrence(s)
Please download and import the following iCalendar (.ics) files to your calendar system.
Weekly: https://us05web.zoom.us/meeting/tZYocuqgqzMuH9IuHUphHIiZ_4T4IndJLToX/ics?icsToken=DJFc88pL6-me_TneLwAALAAAAA70ShjYgLH6RfEnqUm5LK03v2OgtbXujwlKXRMVgIVWCY9aONPJMCycMlkhyPZ3XSrMVVgXDSYlGF_r7DAwMDAwMQ&meetingMasterEventId=MGJmt5lJTd6mPygcS0hiAQ
Join Zoom Meeting
https://us05web.zoom.us/j/82553858456?pwd=fnK5Vb0CcfFpv0lnouILjeEs2z2Khc.1

Meeting ID: 825 5385 8456
Passcode: 182596

Anuj Patnaik

unread,
Jul 18, 2026, 1:03:42 PMJul 18
to leetcode-meetup
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def checkTree(self, root: Optional[TreeNode]) -> bool:
return root.left.val + root.right.val == root.val

Anuj Patnaik

unread,
Jul 18, 2026, 1:07:23 PMJul 18
to leetcode-meetup
class Solution:
def kthSmallest(self, mat: List[List[int]], k: int) -> int:
sums = [0]
for r in range(len(mat)):
new_sums = []
for i in range(len(sums)):
for c in range(len(mat[0])):
new_sums.append(sums[i] + mat[r][c])
new_sums.sort()
sums = new_sums[:k]
return sums[k-1]

Carlos Green

unread,
Jul 18, 2026, 1:40:58 PMJul 18
to leetcode-meetup
/**
* Definition for a binary tree node.
* function TreeNode(val, left, right) {
* this.val = (val===undefined ? 0 : val)
* this.left = (left===undefined ? null : left)
* this.right = (right===undefined ? null : right)
* }
*/
/**
* @param {TreeNode} root
* @return {boolean}
*/
var checkTree = function(root) {
return root.val === root.left.val + root.right.val
};

Anuj Patnaik

unread,
Jul 18, 2026, 1:51:11 PMJul 18
to leetcode-meetup
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def insertIntoMaxTree(self, root: Optional[TreeNode], val: int) -> Optional[TreeNode]:
if root == None:
return TreeNode(val)
if val > root.val:
curr = TreeNode(val)
curr.left = root
curr.right = None
return curr
current = root
while current.right and current.right.val > val:
current = current.right
addition = TreeNode(val)
addition.left = current.right
current.right = addition
return root
Reply all
Reply to author
Forward
0 new messages