2025 January 24 Problems

45 views
Skip to first unread message

daryl...@gmail.com

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

3707. Equal Score Substrings Easy 56.7%




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 24, 2026, 1:13:05 PMJan 24
to leetcode-meetup
class Solution:
def scoreBalance(self, s: str) -> bool:
ind_char = list(s)
for i in range(len(ind_char)):
ind_char[i] = ord(ind_char[i]) - ord("a") + 1
total_sum = sum(ind_char)
l = 0
for j in range(len(ind_char)):
l += ind_char[j]
r = total_sum - l
if r == l:
return True
return False

saurabh s

unread,
Jan 24, 2026, 1:24:24 PMJan 24
to leetcod...@googlegroups.com
class Solution:
def scoreBalance(self, s: str) -> bool:
total_sum = sum(ord(c)-ord('a')+1 for c in s)
if total_sum % 2 != 0:
return False
target = total_sum // 2
current_sum = 0
for c in s:
current_sum += ord(c) - ord('a') + 1
if current_sum == target:
return True
return False


--
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/caf157c5-9be3-4719-a2c1-df6a1f5f73efn%40googlegroups.com.

Allen S.

unread,
Jan 24, 2026, 1:48:05 PMJan 24
to leetcode-meetup
func scoreBalance(s string) bool {
/*
two passes solution
*/
const offset = 'a' - 1
var totalScore rune // rune type is an alias for int32
for _, v := range s {
totalScore += v - offset
}
var prefixScore rune
for _, v := range s {
prefixScore += v - offset
if prefixScore * 2 == totalScore {
return true
}
}
return false
}

On Saturday, January 24, 2026 at 9:57:47 AM UTC-8 daryl...@gmail.com wrote:

Bhupathi Kakarlapudi

unread,
Jan 24, 2026, 2:01:56 PMJan 24
to leetcod...@googlegroups.com
class Solution:
def scoreBalance(self, s: str) -> bool:
score_s = [ord(s[i])-ord('a') + 1 for i in range(len(s))]

lidx:int = 1
ridx:int = 1

while (ridx < len(score_s)):
# left:list = score_s[:lidx]
# right:list = score_s[ridx:]
if (sum(score_s[:lidx]) == sum(score_s[ridx:])):
return True
else:
lidx += 1
ridx += 1

return False

--
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.

vinay

unread,
Jan 24, 2026, 2:03:05 PMJan 24
to leetcod...@googlegroups.com
3707. Equal Score Substrings Easy 56.7%

using prefix sum here. 
time o(n), space o(1)

class Solution {
    public boolean scoreBalance(String s) {
        int totalScore = 0;
        int score = 0;
       
        for(int i = 0; i < s.length(); i++){
            totalScore +=  s.charAt(i) - 'a' +1;
        }

        for(int i = 0; i < s.length(); i++){
            score += s.charAt(i) - 'a' +1;

            if(score == totalScore - score){
                return true;
            }
        }

        return false;
    }
}




On Sat, Jan 24, 2026 at 10:48 AM Allen S. <allen....@gmail.com> wrote:
--

Wang Lijun

unread,
Jan 24, 2026, 2:20:28 PMJan 24
to leetcode-meetup
class Solution:
def scoreBalance(self, s: str) -> bool:
total = 0
for c in s:
total += ord(c) - ord('a') + 1
if total % 2 != 0:
return False
target = total // 2
total = 0
for c in s:
total += ord(c) - ord('a') + 1
if total == target:
return True
return False

Jagrut Sharma

unread,
Jan 24, 2026, 2:25:10 PMJan 24
to leetcod...@googlegroups.com
3707. Equal Score Substrings Easy 56.7%

class Solution:
def scoreBalance(self, s: str) -> bool:
letter_values = {chr(i): i - ord('a') + 1 for i in range(ord('a'), ord('z') + 1)}
sum = 0
target_sum = 0
for i in range(len(s)):
sum += letter_values[s[i]]
if sum % 2 == 1:
return False
target_sum = sum / 2
sum = 0
for i in range(len(s)):
sum += letter_values[s[i]]
if sum == target_sum:
return True
return False
class Solution:
def minArraySum(self, nums: List[int], k: int) -> int:
dp = [float('inf')] * k
res = 0
dp[0] = 0
for n in nums:
res += n # prefix sum
r = res % k
res = min(res, dp[r]) # jump back to smaller sum with same remainder
dp[r] = res
return res



--
Jagrut

Message has been deleted

Rag Mur

unread,
Jan 24, 2026, 2:35:31 PMJan 24
to leetcode-meetup
3707. Equal Score Substrings Easy 56.7%

class Solution:
def scoreBalance(self, s: str) -> bool:
'''
l = 100
this is a rolling sum
bin search wont make muchdifference since you anyway need to look at all the letters
'''

OFFSET = 96
atoi = lambda l: ord(l) - OFFSET
totalScore = sum([atoi(l) for l in s])
if totalScore % 2 > 0:
return False
half = totalScore // 2
rolling_sum = 0
for l in s:
rolling_sum += atoi(l)
if rolling_sum == half:
return True
elif rolling_sum > half:
return False
return False



class Solution:
def minArraySum(self, nums: List[int], k: int) -> int:
'''
the problem can be simpified to find all the disjoint subarrays that are divisible by k and turn them to 0.

this is based on prefix sum theory

prefix_sum[i] means sum(nums[:i+1])
a subarray [i:j] is divisible by k is
(prefix_sum[j] - prefix_sum[i-1]) % k == 0
this means prefix_sum[i-1]) % k == prefix_sum[j]) % k
'''
inf = float('inf')
output = 0
dp = [0] + [inf]*k

for n in nums:
output += n
output = dp[output%k] = min(dp[output%k], output)
return output

-
Raghu


On Saturday, January 24, 2026 at 9:57:47 AM UTC-8 daryl...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages