2026 August 8 Problems

27 views
Skip to first unread message

daryl...@gmail.com

unread,
Aug 8, 2026, 11:30:35 AM (4 days ago) Aug 8
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.

2974. Minimum Number Game Easy 85.7%

2762. Continuous Subarrays Medium 58.0%

Carry over problem:



Here is the meeting url:

Full details:

Topic: Leet Code meeting
Time: Mar 28, 2026 10:00 AM Pacific Time (US and Canada)
        Every week on Sat, 110 occurrence(s)
Please download and import the following iCalendar (.ics) files to your calendar system.
Weekly: https://us05web.zoom.us/meeting/tZYocuqgqzMuH9IuHUphHIiZ_4T4IndJLToX/ics?icsToken=DJFc88pL6-me_TneLwAALAAAAA70ShjYgLH6RfEnqUm5LK03v2OgtbXujwlKXRMVgIVWCY9aONPJMCycMlkhyPZ3XSrMVVgXDSYlGF_r7DAwMDAwMQ&meetingMasterEventId=MGJmt5lJTd6mPygcS0hiAQ
Join Zoom Meeting
https://us05web.zoom.us/j/82553858456?pwd=fnK5Vb0CcfFpv0lnouILjeEs2z2Khc.1

Meeting ID: 825 5385 8456
Passcode: 182596

Jagrut

unread,
Aug 8, 2026, 1:16:50 PM (4 days ago) Aug 8
to leetcode-meetup

class Solution:
def numberGame(self, nums: List[int]) -> List[int]:
n = len(nums)
res = [-1] * n
INC = 2
ar = 0 # Alice read
br = 1 # Bob read
aw = 1 # Alice write
bw = 0 # Bob write
nums_sorted = sorted(nums)
while (br < n):
res[aw] = nums_sorted[ar]
res[bw] = nums_sorted[br]
ar += INC
br += INC
aw += INC
bw += INC
return res

Anuj Patnaik

unread,
Aug 8, 2026, 1:17:29 PM (4 days ago) Aug 8
to leetcode-meetup
import heapq
class Solution:
def numberGame(self, nums: List[int]) -> List[int]:
arr = []
heapq.heapify(nums)
while len(nums) >= 2:
alice_num = heapq.heappop(nums)
bob_num = heapq.heappop(nums)
arr.append(bob_num)
arr.append(alice_num)
return arr

Bhupathi Kakarlapudi

unread,
Aug 8, 2026, 1:57:12 PM (4 days ago) Aug 8
to leetcod...@googlegroups.com
class Solution:
def numberGame(self, nums: List[int]) -> List[int]:
nums.sort()
arr = []
for i in range(0, len(nums), 2):
arr.append(nums[i + 1])
arr.append(nums[i])
return arr

--
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/c25b4acc-8352-4680-b112-4dc3e4f9100an%40googlegroups.com.

Jagrut

unread,
Aug 8, 2026, 2:22:08 PM (4 days ago) Aug 8
to leetcode-meetup

class Solution:
def continuousSubarrays(self, nums: List[int]) -> int:
# indices of max elements in decreasing order in valid window
maxq = deque()
# indices of min elements in increasing order in valid window
minq = deque()

# start of window
i = 0
# result count
res = 0

for j, n in enumerate(nums):
# maxq maintenance
while maxq and nums[maxq[len(maxq) - 1]] < n:
maxq.pop()
maxq.append(j)

# minq maintenance
while minq and nums[minq[len(minq) - 1]] > n:
minq.pop()
minq.append(j)

# make sure window is valid wrt min - max element criteria
while maxq and minq and abs(nums[maxq[0]] - nums[minq[0]]) > 2:
# one of maxq[0] or minq[0] needs to be taken out
# then condition needs to be checked again
# find the one that occurs earlier
# take that out since it will keep the other
# if you take out the one that occurs later,
# it basically means removing both
if maxq[0] < minq[0]:
i = maxq.popleft() + 1
else:
i = minq.popleft() + 1

# now window is valid wrt min - max criteria
# i and j are the boundary indices
res += j - i + 1

return res

Reply all
Reply to author
Forward
0 new messages