11-Macd

Fri 14 November 2025
# Created: 20250103
import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml312-2024; pyv: 3.12.7 | packaged by Anaconda, Inc. | (main, Oct  4 2024, 13:27:36) [GCC 11.2.0]'
print(pyu.ps2("requests"))
requests==2.32.3
import yfinance as yf
import pandas as pd
import matplotlib.pyplot …

Category: stockmarket

Read More

110-Balanced-Binary-Tree

Fri 14 November 2025

https://leetcode.com/problems/balanced-binary-tree

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def isBalanced(self, root: Optional[TreeNode]) -> bool:
    if not root:
      return True

    def maxDepth(root: Optional[TreeNode]) -> int:
      if not root:
        return 0
      return 1 + max(maxDepth(root.left …

Category: leetcode

Read More

111-Minimum-Depth-Of-Binary-Tree

Fri 14 November 2025

https://leetcode.com/problems/minimum-depth-of-binary-tree

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def minDepth(self, root: Optional[TreeNode]) -> int:
    if not root:
      return 0
    if not root.left:
      return self.minDepth(root.right) + 1
    if not root.right:
      return self.minDepth …

Category: leetcode

Read More

112-Path-Sum

Fri 14 November 2025

https://leetcode.com/problems/path-sum

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def hasPathSum(self, root: TreeNode, summ: int) -> bool:
    if not root:
      return False
    if root.val == summ and not root.left and not root.right:
      return True
    return self …

Category: leetcode

Read More

113-Path-Sum-Ii

Fri 14 November 2025

https://leetcode.com/problems/path-sum-ii

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def pathSum(self, root: TreeNode, summ: int) -> List[List[int]]:
    ans = []

    def dfs(root: TreeNode, summ: int, path: List[int]) -> None:
      if not root:
        return
      if root.val == summ …

Category: leetcode

Read More

114-Flatten-Binary-Tree-To-Linked-List

Fri 14 November 2025

https://leetcode.com/problems/flatten-binary-tree-to-linked-list

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def flatten(self, root: Optional[TreeNode]) -> None:
    if not root:
      return

    self.flatten(root.left)
    self.flatten(root.right)

    left = root.left  # Flattened left
    right = root.right  # Flattened right …

Category: leetcode

Read More

115-Distinct-Subsequences

Fri 14 November 2025

https://leetcode.com/problems/distinct-subsequences

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def numDistinct(self, s: str, t: str) -> int:
    m = len(s)
    n = len(t)
    dp = [[0] * (n + 1) for _ in range(m + 1)]

    for i in range(m …

Category: leetcode

Read More

116-Populating-Next-Right-Pointers-In-Each-Node

Fri 14 November 2025

https://leetcode.com/problems/populating-next-right-pointers-in-each-node

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def connect(self, root: 'Optional[Node]') -> 'Optional[Node]':
    if not root:
      return None

    def connectTwoNodes(p, q) -> None:
      if not p:
        return
      p.next = q
      connectTwoNodes(p.left, p …

Category: leetcode

Read More

117-Populating-Next-Right-Pointers-In-Each-Node-Ii

Fri 14 November 2025

https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def connect(self, root: 'Node') -> 'Node':
    node = root  # The node just above current needling

    while node:
      dummy = Node(0)  # Dummy node before needling
      # Needle children of node
      needle = dummy …

Category: leetcode

Read More

118-Pascals-Triangle

Fri 14 November 2025

https://leetcode.com/problems/pascals-triangle

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def generate(self, numRows: int) -> List[List[int]]:
    ans = []

    for i in range(numRows):
      ans.append([1] * (i + 1))

    for i in range(2, numRows):
      for j in range …

Category: leetcode

Read More
Page 9 of 146

« Prev Next »