TRTapan Rachchhintapanrachchh.hashnode.dev·Feb 9 · 1 min read1382. Balance a Binary Search Tree# 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 balanceBST(self, root: TreeNode) -...00
TRTapan Rachchhintapanrachchh.hashnode.dev·Feb 1 · 1 min read3010. Divide an Array Into Subarrays With Minimum Cost Iclass Solution: def minimumCost(self, nums: List[int]) -> int: return nums.pop(0) + sum(sorted(nums)[:2])00
TRTapan Rachchhintapanrachchh.hashnode.dev·Jan 24 · 1 min read3507. Minimum Pair Removal to Sort Array Iclass Solution: def minimumPairRemoval(self, nums: List[int]) -> int: def checkSorted(arr): return arr == sorted(arr) def findAndMerge(arr): minSum = float("inf") trackIndex = -1 ...00
TRTapan Rachchhintapanrachchh.hashnode.dev·Jan 24 · 1 min read1877. Minimize Maximum Pair Sum in Arrayclass Solution: def minPairSum(self, nums: List[int]) -> int: ''' Sort it out Scan and track max sum ''' nums.sort() l = len(nums) maxSum = 0 for i in range(l//2): ...00
TRTapan Rachchhintapanrachchh.hashnode.dev·Jun 29, 2025 · 4 min readSolving a 2 Year Old Problem on LeetcodeHey folks! Today I encounted a problem which I tried solving 2 years back (2023) Question Link → 1498. Number of Subsequences That Satisfy the Given Sum Condition So, looking at my 2 year old attempt, I wanted to challenge myself to solve it this ti...00