2026 January 17 Problems

39 views
Skip to first unread message

daryl...@gmail.com

unread,
Jan 17, 2026, 12:47:55 PMJan 17
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.

Second hard problem is carried over from last week.





We're going to use the same Google meet link as the last few times: https://meet.google.com/xnn-kifj-jnx?pli=1

Anuj Patnaik

unread,
Jan 17, 2026, 1:11:06 PMJan 17
to leetcode-meetup
class Solution:
def minimumPairRemoval(self, nums: List[int]) -> int:
if Solution.is_Sorted(nums) or len(nums) == 1:
return 0
if len(nums) == 2:
return 1
op = 0
while(Solution.is_Sorted(nums) == False):
min_sum = nums[0] + nums[1]
min_sum_index = 0
for j in range(len(nums) - 1):
curr_pair_sum = nums[j] + nums[j+1]
if curr_pair_sum < min_sum:
min_sum = curr_pair_sum
min_sum_index = j
if min_sum_index + 2 == len(nums):
nums = nums[:min_sum_index] + [min_sum]
op += 1
else:
nums = nums[:min_sum_index] + [min_sum] + nums[min_sum_index + 2:]
op += 1
return op

def is_Sorted(nums):
if len(nums) == 0:
return False
if len(nums) == 1:
return True
isSorted = False
for i in range(len(nums) - 1):
if nums[i] > nums[i+1]:
return False
return True

Bhupathi Kakarlapudi

unread,
Jan 17, 2026, 3:03:03 PMJan 17
to leetcod...@googlegroups.com
class Solution:
def scanForNonDecreasing(self, narray:List[int]) -> bool:
for i in range(len(narray)-1):
if narray[i+1] < narray[i]:
return False
return True

def findMinSum(self, narray:List[int]) -> int:
minSum:int = -10000
sum:int = 0
for i in range(len(narray)-1):
sum = narray[i] + narray[i+1]
if minSum == -10000:
minSum = sum
else:
if sum < minSum:
minSum = sum
return minSum

def replaceMinSum(self, narray:List[int], minSum) -> List[int]:
for i in range(len(narray)-1):
sum = narray[i] + narray[i+1]
if minSum == sum:
narray[i] = minSum
del narray[i+1]
break

return narray
def minimumPairRemoval(self, nums: List[int]) -> int:
minOps:int = 0

while(True):
#narray:List[int] = nums
if self.scanForNonDecreasing(nums):
break
minSum:int = self.findMinSum(nums)
# print(f"minSum:{minSum}")
nums:List = self.replaceMinSum(nums, minSum)
# print(f"narray:{narray}")
minOps += 1

# print(f"minOps:{minOps}")

return minOps

--
whatspp group: http://whatsapp.techbayarea.us/
---
You received this message because you are subscribed to the Google Groups "leetcode-meetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leetcode-meet...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/leetcode-meetup/584c5285-d105-46f9-ae7e-64d855fefb04n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages