2026 June 6 Problems

33 views
Skip to first unread message

daryl...@gmail.com

unread,
Jun 6, 2026, 12:52:45 PM (13 days ago) Jun 6
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.


888. Fair Candy Swap Easy 65.1%

Problems carried over from last week:


We will have a different Zoom meeting that Bhupathi is providing this week:

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

Bhupathi Kakarlapudi

unread,
Jun 6, 2026, 2:27:20 PM (12 days ago) Jun 6
to leetcod...@googlegroups.com
class Solution:
def fairCandySwap(self, aliceSizes: List[int], bobSizes: List[int]) -> List[int]:
sumA = sum(aliceSizes)
sumB = sum(bobSizes)
# If Alice gives x and gets y:
# sumA - x + y == sumB - y + x
# => y - x = (sumB - sumA) // 2
# => y = x + (sumB - sumA) // 2
bob_set = set(bobSizes)
for x in aliceSizes:
y = x + (sumB - sumA) // 2
if y in bob_set:
return [x, y]
return []

--
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/e0a50d30-23e3-4243-9924-d13dcb8e6544n%40googlegroups.com.

Anuj Patnaik

unread,
Jun 6, 2026, 2:32:12 PM (12 days ago) Jun 6
to leetcode-meetup
class Solution:
def maxProfit(self, prices: List[int], strategy: List[int], k: int) -> int:
base = 0
for i in range(len(prices)):
base += prices[i] * strategy[i]
first_half = []
second_half = []
for i in range(len(prices)):
first_half.append(-strategy[i] * prices[i])
second_half.append(prices[i] -strategy[i] * prices[i])
prefix_sum_first_half = [0]
prefix_sum_second_half = [0]
for j in range(len(first_half)):
prefix_sum_first_half.append(prefix_sum_first_half[j] + first_half[j])
prefix_sum_second_half.append(prefix_sum_second_half[j] + second_half[j])
max_delta = 0
for l in range(len(prices) - k + 1):
mid_pt = l + int(k//2)
right_pt = l + k
curr_delta = prefix_sum_first_half[mid_pt] - prefix_sum_first_half[l] + prefix_sum_second_half[right_pt] - prefix_sum_second_half[mid_pt]
max_delta = max(curr_delta, max_delta)
return base + max_delta










Reply all
Reply to author
Forward
0 new messages