1-Gridsearchcv-1

Sat 17 May 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
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.metrics import accuracy_score
# Load …

Category: hyperparam-tuning

Read More

1-Matplotlib-1

Sat 17 May 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]'

'conda env: ml312-2024; pyv: 3.12.7 | packaged by Anaconda, Inc. | (main, Oct  4 2024, 13:27:36) [GCC 11 …

Category: plot-compare

Read More

1-Two-Sum

Sat 17 May 2025

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

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def twoSum(self, nums: List[int], target: int) -> List[int]:
    numToIndex = {}

    for i, num in enumerate(nums):
      if target - num in numToIndex:
        return numToIndex[target - num], i
      numToIndex[num …

Category: leetcode

Read More

1-Two-Sums

Sat 17 May 2025
# https://leetcode.com/problems/two-sum
import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml311; pyv: 3.11.10 (main, Oct  3 2024, 07:29:13) [GCC 11.2.0]'
print(pyu.ps2("haystack-ai ollama-haystack python-dotenv"))
haystack-ai==2.8.0
ollama-haystack is not installed in the current environment.
python-dotenv==0.21 …

Category: leetcode

Read More

10-Regular-Expression-Matching

Sat 17 May 2025

https://leetcode.com/problems/regular-expression-matching

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def isMatch(self, s: str, p: str) -> bool:
    m = len(s)
    n = len(p)
    # dp[i][j] := True if s[0..i) matches p[0..j)
    dp = [[False] * (n …

Category: leetcode

Read More

10-Relative-Strength-Index

Sat 17 May 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

10-Vaex-1

Sat 17 May 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 vaex
# vaex is not supported in 3.12
!pip show vaex | grep "Version:"
WARNING: Package(s) not found: vaex …

Category: plot-compare

Read More

100-Same-Tree

Sat 17 May 2025

https://leetcode.com/problems/same-tree

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def isSameTree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool:
    if not p or not q:
      return p == q
    return p.val == q.val and \
        self.isSameTree(p.left …

Category: leetcode

Read More

1001-Grid-Illumination

Sat 17 May 2025

https://leetcode.com/problems/grid-illumination

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def gridIllumination(self, N: int, lamps: List[List[int]], queries: List[List[int]]) -> List[int]:
    ans = []
    rows = Counter()
    cols = Counter()
    diag1 = Counter()
    diag2 = Counter()
    lampsSet = set()

    for i, j …

Category: leetcode

Read More

1002-Find-Common-Characters

Sat 17 May 2025

https://leetcode.com/problems/find-common-characters

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def commonChars(self, A: List[str]) -> List[str]:
    ans = []
    commonCount = [math.inf] * 26

    for a in A:
      count = [0] * 26
      for c in a:
        count[ord(c) - ord('a …

Category: leetcode

Read More
Page 2 of 146

« Prev Next »