5-Altair-1

Fri 14 November 2025
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]'

#!pip install altair
!pip show altair | grep "Version:"
Version: 5.5.0
import altair as alt
import pandas as pd

data …

Category: plot-compare

Read More

5-Hyperband-1

Fri 14 November 2025

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]'

import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn …

Category: hyperparam-tuning

Read More

5-Longest-Palindromic-Substring

Fri 14 November 2025

https://leetcode.com/problems/longest-palindromic-substring

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def longestPalindrome(self, s: str) -> str:
    if not s:
      return ''

    indices = [0, 0]

    # Returns [start, end] indices of the longest palindrome extended from s[i..j]
    def extend(s …

Category: leetcode

Read More

50-Heikin-Ashi-Candles

Fri 14 November 2025
# Created: 20250104
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]'
# !pip install mplfinance
print(pyu.ps2("yfinance pandas matplotlib"))
yfinance==0.2.51
pandas==2.2.3
matplotlib==3 …

Category: stockmarket

Read More

50-Powx-N

Fri 14 November 2025

https://leetcode.com/problems/powx-n

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def myPow(self, x: float, n: int) -> float:
    if n == 0:
      return 1
    if n < 0:
      return 1 / self.myPow(x, -n)
    if n & 1:
      return x * self.myPow …

Category: leetcode

Read More

500-Keyboard-Row

Fri 14 November 2025

https://leetcode.com/problems/keyboard-row

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def findWords(self, words: List[str]) -> List[str]:
    ans = []
    rows = [set('qwertyuiop'), set('asdfghjkl'), set('zxcvbnm')]

    for word in words:
      lowerWord = set(word.lower())
      if any(lowerWord <= row for …

Category: leetcode

Read More

501-Find-Mode-In-Binary-Search-Tree

Fri 14 November 2025

https://leetcode.com/problems/find-mode-in-binary-search-tree

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def findMode(self, root: Optional[TreeNode]) -> List[int]:
    self.ans = []
    self.pred = None
    self.count = 0
    self.maxCount = 0

    def updateCount(root: Optional[TreeNode]) -> None:
      if self.pred and …

Category: leetcode

Read More

507-Perfect-Number

Fri 14 November 2025

https://leetcode.com/problems/perfect-number

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def checkPerfectNumber(self, num: int) -> bool:
    return num in {6, 28, 496, 8128, 33550336}
new Solution().checkPerfectNumber()

Score: 5

Category: leetcode

Read More

508-Most-Frequent-Subtree-Sum

Fri 14 November 2025

https://leetcode.com/problems/most-frequent-subtree-sum

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

    count = Counter()

    def dfs(root: Optional[TreeNode]) -> int:
      if not root:
        return 0

      summ = root.val + dfs …

Category: leetcode

Read More

509-Fibonacci-Number

Fri 14 November 2025

https://leetcode.com/problems/fibonacci-number

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def fib(self, N: int) -> int:
    if N < 2:
      return N

    dp = [0, 0, 1]

    for i in range(2, N + 1):
      dp[0] = dp[1]
      dp[1] = dp …

Category: leetcode

Read More
Page 45 of 146

« Prev Next »