post_href stringlengths 57 213 | python_solutions stringlengths 71 22.3k | slug stringlengths 3 77 | post_title stringlengths 1 100 | user stringlengths 3 29 | upvotes int64 -20 1.2k | views int64 0 60.9k | problem_title stringlengths 3 77 | number int64 1 2.48k | acceptance float64 0.14 0.91 | difficulty stringclasses 3
values | __index_level_0__ int64 0 34k |
|---|---|---|---|---|---|---|---|---|---|---|---|
https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/discuss/1383632/Python3-%3A-simple-93-faster | class Solution:
def countGoodSubstrings(self, s: str) -> int:
count=0
for i in range(0,len(s)-2):
if len(set(s[i:i+3])) == 3:
count+=1
return count | substrings-of-size-three-with-distinct-characters | Python3 : simple 93% faster | p_a | 0 | 52 | substrings of size three with distinct characters | 1,876 | 0.703 | Easy | 26,600 |
https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/discuss/1339461/Python-O(n)-Sliding-Window-Technique-Hashmap | class Solution(object):
def countGoodSubstrings(self, s):
"""
:type s: str
:rtype: int
"""
if len(s) < 3:
return 0
count = 0
i, j = 0, 0
has = {}
while j < len(s):
if j-i == 3:
count += 1
... | substrings-of-size-three-with-distinct-characters | Python O(n) Sliding Window Technique Hashmap | Sibu0811 | 0 | 145 | substrings of size three with distinct characters | 1,876 | 0.703 | Easy | 26,601 |
https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/discuss/1327994/Python-Easy-Simple-O(n) | class Solution(object):
def countGoodSubstrings(self, s):
count=0
for each in range(2,len(s)+1):
if len(set(s[each-3:each])) == 3:
count+=1
return count | substrings-of-size-three-with-distinct-characters | Python Easy Simple O(n) | akashadhikari | 0 | 50 | substrings of size three with distinct characters | 1,876 | 0.703 | Easy | 26,602 |
https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/discuss/1255635/Python3-or-Generalized-Solution-or-o(n) | class Solution:
def countGoodSubstrings(self, s: str) -> int:
seen = set()
req_len = 3
start = 0
ans = 0
for i in range(len(s)):
if i-start == req_len:
seen.discard(s[start])
start+=1
while s[i]... | substrings-of-size-three-with-distinct-characters | Python3 | Generalized Solution | o(n) | Sanjaychandak95 | 0 | 30 | substrings of size three with distinct characters | 1,876 | 0.703 | Easy | 26,603 |
https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/discuss/1238893/PythonPython3-solution-in-6-lines-with-explanation | class Solution:
def countGoodSubstrings(self, s: str) -> int:
cnt = 0 #to count the distinct character substring of length 3
for i in range(len(s)-2):
subStr = s[i:i+3] #compute the substring
if len(set(subStr)) == 3: #if set of subStr length is equal to 3 then increment cnt ... | substrings-of-size-three-with-distinct-characters | Python/Python3 solution in 6 lines with explanation | prasanthksp1009 | 0 | 41 | substrings of size three with distinct characters | 1,876 | 0.703 | Easy | 26,604 |
https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/discuss/1238864/Python%3A-Find-all-substrings-of-length-3-and-then-find-unique. | class Solution:
def countGoodSubstrings(self, s: str) -> int:
substring = []
for i in range(0,len(s)-2):
a = s[i:i+3]
substring.append(a)
ans = 0
for i in substring:
if len(set(i)) == 3:
ans += 1
return ans | substrings-of-size-three-with-distinct-characters | Python: Find all substrings of length 3 and then find unique. | harshhx | 0 | 437 | substrings of size three with distinct characters | 1,876 | 0.703 | Easy | 26,605 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2087728/Python-Easy-To-Understand-Code-oror-Beginner-Friendly-oror-Brute-Force | class Solution:
def minPairSum(self, nums: List[int]) -> int:
pair_sum = []
nums.sort()
for i in range(len(nums)//2):
pair_sum.append(nums[i]+nums[len(nums)-i-1])
return max(pair_sum) | minimize-maximum-pair-sum-in-array | Python Easy To Understand Code || Beginner Friendly || Brute Force | Shivam_Raj_Sharma | 5 | 207 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,606 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1725067/Python-or-Sort-and-Two-Pointers | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
i = 0
j = len(nums) - 1
res = 0
while i < j:
res = max(res, nums[i] + nums[j])
i += 1
j -= 1
return res | minimize-maximum-pair-sum-in-array | Python | Sort and Two Pointers | jgroszew | 4 | 258 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,607 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1292471/Python-fast-and-pythonic | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
return max([value+nums[-index] for index, value in enumerate(nums[:len(nums)//2], 1)]) | minimize-maximum-pair-sum-in-array | [Python] fast and pythonic | cruim | 2 | 340 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,608 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2327399/Python-or-Easy-and-Fast-Solution-or-Two-pointer | class Solution:
def minPairSum(self, nums: List[int]) -> int:
ans = 0
nums.sort()
l, r = 0, len(nums)-1
while l<r:
ans = max(ans, nums[l]+nums[r])
l += 1
r -= 1
return ans | minimize-maximum-pair-sum-in-array | Python | Easy & Fast Solution | Two pointer | desalichka | 1 | 46 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,609 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1653815/Python-simple-two-pointers-solution-after-sort | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
n = len(nums)
res = 0
l, r = 0, n-1
while l < r:
res = max(res, nums[l] + nums[r])
l += 1
r -= 1
return res | minimize-maximum-pair-sum-in-array | Python simple two-pointers solution after sort | byuns9334 | 1 | 72 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,610 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1359976/Sort-and-zip-98-speed | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
half_len_nums = len(nums) // 2
return max(a + b for a, b in zip(nums[:half_len_nums:],
nums[-1:half_len_nums - 1: -1])) | minimize-maximum-pair-sum-in-array | Sort and zip, 98% speed | EvgenySH | 1 | 157 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,611 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1276736/Python3-simple-solution-using-sorting-and-single-while-loop-beats-90-users | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
i,j = 0, len(nums)-1
res = []
while i < j:
res.append(nums[i]+nums[j])
i += 1
j -= 1
return max(res) | minimize-maximum-pair-sum-in-array | Python3 simple solution using sorting and single while loop beats 90% users | EklavyaJoshi | 1 | 68 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,612 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1245842/python3-Simple-solution-beats-99.43-of-python3-submissions. | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
return max([nums[x]+nums[-x-1] for x in range(len(nums)//2)]) | minimize-maximum-pair-sum-in-array | [python3] Simple solution, beats 99.43 % of python3 submissions. | SushilG96 | 1 | 181 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,613 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1238919/Python-oror-sort | class Solution:
def minPairSum(self, nums: List[int]) -> int:
pairs = []
nums = sorted(nums)
n = len(nums)
for i in range(len(nums)//2):
a = [nums[i],nums[n-i-1]]
pairs.append(a)
sum_ = []
for i,j in pairs:
sum_.append(i+j)
... | minimize-maximum-pair-sum-in-array | Python || sort | harshhx | 1 | 87 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,614 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1238865/PythonPython3-solution-in-5-lines-with-explanation | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort() # sort the numbers
lis = [] # to store the res and it takes O(n) space complexity
for i in range(len(nums)//2): # traverse the loop to length(nums)/2 times
lis.append(nums[i]+nums[~i]) #add the indexes 0+(-... | minimize-maximum-pair-sum-in-array | Python/Python3 solution in 5 lines with explanation | prasanthksp1009 | 1 | 95 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,615 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1238865/PythonPython3-solution-in-5-lines-with-explanation | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()# sort the numbers
maxi = 0 # to store the maximum value and it takes only O(1) space complexity
for i in range(len(nums)//2):# traverse the loop to length(nums)/2 times
maxi = max(maxi,nums[i]+nums[~i])#add... | minimize-maximum-pair-sum-in-array | Python/Python3 solution in 5 lines with explanation | prasanthksp1009 | 1 | 95 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,616 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2845420/Python-easy-solution | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
n=len(nums)
ot=[]
for i in range(n//2):
ot.append(nums[i]+nums[n-i-1])
return max(ot) | minimize-maximum-pair-sum-in-array | Python easy solution | patelhet050603 | 0 | 2 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,617 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2834978/Python3-2-liner-beats-97.2888.60 | class Solution:
def minPairSum(self, nums):
nums.sort()
return max(nums[i]+nums[-1*i-1] for i in range(len(nums))) | minimize-maximum-pair-sum-in-array | [Python3] 2-liner, beats 97.28%/88.60% | U753L | 0 | 3 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,618 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2821014/Simple-two-pointers-solution | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
i = 0
j = len(nums)-1
max_sum = 0
while i < j:
max_sum = max(max_sum, nums[i] + nums[j])
i += 1
j -= 1
return max_sum | minimize-maximum-pair-sum-in-array | Simple two pointers solution | khaled_achech | 0 | 1 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,619 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2805309/Python-Solution-EASY-TO-UNDERSTAND | class Solution:
def minPairSum(self, nums: List[int]) -> int:
m=0
nums.sort()
n=len(nums)
for i in range(n//2):
m=max(m,nums[i]+nums[n-i-1])
return m | minimize-maximum-pair-sum-in-array | Python Solution - EASY TO UNDERSTAND | T1n1_B0x1 | 0 | 4 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,620 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2801513/Fast-and-memory-efficient-solution | class Solution:
def minPairSum(self, nums: List[int]) -> int:
h = []
heapq.heapify(nums)
for i in range(len(nums)):
h.append(heapq.heappop(nums))
right = len(h)-1
m = 0
for left in range(len(h)//2):
m = max(m, (h[left]+h[right]))
... | minimize-maximum-pair-sum-in-array | Fast and memory efficient solution | AndreySmirnov | 0 | 1 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,621 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2785585/Python3-solution | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
res = []
i, j = 0, len(nums) - 1
while i < j:
res.append(nums[i] + nums[j])
i += 1
j -= 1
return max(res) | minimize-maximum-pair-sum-in-array | Python3 solution | mediocre-coder | 0 | 2 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,622 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2782495/Python3-Solution-with-explanation-beats-99-in-memory | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
max_sum=0
for i in range(len(nums)//2):
max_sum = max(max_sum, nums.pop(0)+nums.pop(len(nums)-1))
return max_sum | minimize-maximum-pair-sum-in-array | Python3 Solution with explanation, beats 99% in memory | sipi09 | 0 | 2 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,623 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2777553/Python-simple-solution-using-sort | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
n = len(nums)
maxi = 0
for i in range(n//2):
print(nums[n-1])
if nums[i]+nums[n-1-i]>maxi:
maxi = nums[i]+nums[n-1-i]
return maxi | minimize-maximum-pair-sum-in-array | Python simple solution using sort | Rajeev_varma008 | 0 | 2 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,624 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2719124/Python-Sorting-O(nlogn) | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
ans = []
for i in range(len(nums)//2):
ans.append(nums[i] + nums[~i])
return max(ans) | minimize-maximum-pair-sum-in-array | Python Sorting O(nlogn) | axce1 | 0 | 6 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,625 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2689639/Simple-Python-Solution-or-Sorting-or-Two-Pointers | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
maxi=0
n=len(nums)
for i in range(n//2):
maxi=max(maxi, nums[i]+nums[-i-1])
return maxi | minimize-maximum-pair-sum-in-array | Simple Python Solution | Sorting | Two Pointers | Siddharth_singh | 0 | 7 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,626 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2643880/Python-or-Simple-Solution | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
maxVal = 0
j = len(nums)-1
for i in range(len(nums)//2):
maxVal = max(maxVal, nums[i]+nums[j])
j-=1
return maxVal | minimize-maximum-pair-sum-in-array | Python | Simple Solution | naveenraiit | 0 | 4 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,627 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2410988/Simple-python-code-with-explanation | class Solution:
#using sorting and two pointers approach
def minPairSum(self, nums: List[int]) -> int:
#create a new list to store sum of pairs
sumofpairs = []
#sort the elements
nums.sort()
#let l pointer be at 0th index
... | minimize-maximum-pair-sum-in-array | Simple python code with explanation | thomanani | 0 | 14 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,628 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2242405/Python-Solution | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
return max([nums[i]+nums[~i] for i in range(len(nums)//2)]) | minimize-maximum-pair-sum-in-array | Python Solution | SakshiMore22 | 0 | 39 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,629 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2175328/Python-or-Easy-solution-using-two-pointers-technique | class Solution:
def minPairSum(self, nums: List[int]) -> int:
# ///// TC: O(nlogn) and SC: O(n) ////
nums.sort()
res = []
l,r = 0, len(nums) - 1
while l < r:
pairSum = nums[l] + nums[r]
res.append(pairSum)
l += 1
r -= 1
... | minimize-maximum-pair-sum-in-array | Python | Easy solution using two pointers technique | __Asrar | 0 | 33 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,630 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2174776/Python3-Very-simple-solution-with-sort | class Solution:
def minPairSum(self, nums: List[int]) -> int:
## RC ##
## APPROACH: MATH ##
nums.sort()
res = 0
n = len(nums)
for i in range(n//2):
res = max(nums[i] + nums[n-1-i], res)
return res | minimize-maximum-pair-sum-in-array | [Python3] Very simple solution with sort | 101leetcode | 0 | 21 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,631 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1991533/Python-Solution-or-Sorting-and-Two-Pointers-or-Clean-Code | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
N = len(nums)
maxPairSum = 0
left = 0
right = N-1
while left < right:
maxPairSum = max(maxPairSum,nums[left] + nums[right])
left += 1
right -= 1
retur... | minimize-maximum-pair-sum-in-array | Python Solution | Sorting and Two Pointers | Clean Code | Gautam_ProMax | 0 | 41 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,632 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1706581/Understandable-code-for-beginners-like-me-in-python-!! | class Solution:
def minPairSum(self, nums: List[int]) -> int:
pairsum,maxSum=0,0
nums.sort()
nums_len=len(nums)
half_len=nums_len//2
for index in range(half_len):
pairsum=nums[index]+nums[nums_len-index-1]
if(pairsum>maxSum):
maxSum=pai... | minimize-maximum-pair-sum-in-array | Understandable code for beginners like me in python !! | kabiland | 0 | 64 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,633 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1705074/Simple-python3-solution-with-description-and-example | class Solution:
def minPairSum(self, nums: List[int]) -> int: #eg - [3,5,2,3]
nums = sorted(nums) # sort list in ascending order => [2,3,3,5]
i = 0 # two pointer i and j => nums[i] = 2 and nums[j] = 5
j = len(nums)-1
lis = []
... | minimize-maximum-pair-sum-in-array | Simple python3 solution with description and example | KratikaRathore | 0 | 61 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,634 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1561707/Py3-Simple-solution-using-zip | class Solution:
def minPairSum(self, nums: List[int]) -> int:
res = 0
n = len(nums)
if n%2 == 0:
nums.sort()
for x, y in zip(nums[:n//2], nums[n//2:][::-1]):
res = max(res, x+y)
return res | minimize-maximum-pair-sum-in-array | [Py3] Simple solution using zip | ssshukla26 | 0 | 66 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,635 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1521050/Python-Heap | class Solution:
def minPairSum(self, nums: List[int]) -> int:
max_heap, min_heap = [-i for i in nums], nums
heapify(min_heap)
heapify(max_heap)
return max([
-heappop(max_heap) + heappop(min_heap)
for i in range(len(nums) // 2... | minimize-maximum-pair-sum-in-array | [Python] Heap | dev-josh | 0 | 62 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,636 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1494755/Python-3-oror-Faster-than-95-ororSimple-2-ptr | class Solution:
def minPairSum(self, nums: List[int]) -> int:
n=len(nums)
i,j = 0,n-1
nums.sort()
max_sum = float("-inf")
while(i<n//2):
max_sum = max(nums[i]+nums[j],max_sum)
i+=1
j-=1
return max_sum | minimize-maximum-pair-sum-in-array | Python 3 || Faster than 95% ||Simple 2 ptr | ana_2kacer | 0 | 113 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,637 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1459604/Python3-Solution-with-using-sorting | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
_max = 0
for idx in range(len(nums) // 2):
_max = max(_max, nums[idx] + nums[len(nums) - 1 - idx])
return _max | minimize-maximum-pair-sum-in-array | [Python3] Solution with using sorting | maosipov11 | 0 | 131 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,638 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1387779/Python-oror-O(n)-oror-Count-Sort-oror-Easy-Solution-oror-beat-100-speed-and-memory | class Solution:
def minPairSum(self, nums: List[int]) -> int:
self.myCountSort(nums)
asc = nums[0:len(nums)//2]
desc = nums[len(nums)//2:][::-1]
max_val, temp = 0, 0
for asc_val,desc_val in zip(asc,desc):
temp = asc_val+desc_val
... | minimize-maximum-pair-sum-in-array | Python || O(n) || Count Sort || Easy Solution || beat 100% speed and memory | zafarman | 0 | 173 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,639 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1268312/Python-faster-than-95-O(nlogn) | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums = sorted(nums)
ans = nums[0]
for i in range(len(nums)//2):
pair_sum = nums[i] + nums[len(nums) -i - 1]
if pair_sum > ans:
ans = pair_sum
return ans | minimize-maximum-pair-sum-in-array | Python faster than 95% O(nlogn) | user5573CJ | 0 | 84 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,640 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1239052/Python3-greedy | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
return max(nums[i] + nums[~i] for i in range(len(nums)//2)) | minimize-maximum-pair-sum-in-array | [Python3] greedy | ye15 | 0 | 35 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,641 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1239052/Python3-greedy | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
ans = 0
for i in range(len(nums)//2):
ans = max(ans, nums[i] + nums[~i])
return ans | minimize-maximum-pair-sum-in-array | [Python3] greedy | ye15 | 0 | 35 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,642 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/2309773/Python-oror-Time-O(n)-two-pointer-solution | class Solution:
def minPairSum(self, nums: List[int]) -> int:
res = 0
nums.sort()
i,j = 0 , len(nums)-1
while(i<j):
res = max(res , nums[i]+nums[j])
i+=1
j-=1
return res | minimize-maximum-pair-sum-in-array | Python || Time O(n) two-pointer solution | ronipaul9972 | -1 | 34 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,643 |
https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/discuss/1657614/Python-oror-O(nlogn)-time-oror-O(1)-spaceoror-sorting-oror-2-pointers | class Solution:
def minPairSum(self, nums: List[int]) -> int:
nums.sort()
start, end = 0, len(nums) - 1
max_sum = 0
while start <= end:
curr_sum = nums[start] + nums[end]
max_sum = max(max_sum,curr_sum)
start += 1
end -= 1
retur... | minimize-maximum-pair-sum-in-array | Python || O(nlogn) time || O(1) space|| sorting || 2 pointers | s_m_d_29 | -1 | 95 | minimize maximum pair sum in array | 1,877 | 0.803 | Medium | 26,644 |
https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/discuss/1239929/python-oror-100-faster-oror-well-explained-oror-Simple-approach | class Solution:
def getBiggestThree(self, grid: List[List[int]]) -> List[int]:
def calc(l,r,u,d):
sc=0
c1=c2=(l+r)//2
expand=True
for row in range(u,d+1):
if c1==c2:
sc+=grid[row][c1]
else:
sc+=grid[row][c1]+grid[row][c2]
... | get-biggest-three-rhombus-sums-in-a-grid | 🐍 {python} || 100% faster || well-explained || Simple approach | abhi9Rai | 6 | 721 | get biggest three rhombus sums in a grid | 1,878 | 0.464 | Medium | 26,645 |
https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/discuss/1442967/Python-3-or-DP-Matrix-Padding-Prefix-Sum-or-Explanation | class Solution:
def getBiggestThree(self, grid: List[List[int]]) -> List[int]:
m, n = len(grid), len(grid[0])
dp = [[[0, 0]] * (n+2) for _ in range(m+2)]
ans = []
for i in range(1, m+1):
for j in range(1, n+1): # [i, j] will be the bottom vertex... | get-biggest-three-rhombus-sums-in-a-grid | Python 3 | DP, Matrix Padding, Prefix Sum | Explanation | idontknoooo | 2 | 659 | get biggest three rhombus sums in a grid | 1,878 | 0.464 | Medium | 26,646 |
https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/discuss/1360208/Brute-force-75-speed | class Solution:
def getBiggestThree(self, grid: List[List[int]]) -> List[int]:
first = second = third = 0
def update_sums(val):
nonlocal first, second, third
if val > first:
third = second
second = first
first = val
... | get-biggest-three-rhombus-sums-in-a-grid | Brute force, 75% speed | EvgenySH | 1 | 337 | get biggest three rhombus sums in a grid | 1,878 | 0.464 | Medium | 26,647 |
https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/discuss/1242382/1878.-Get-Biggest-Three-Rhombus-Sums-in-a-Grid-oror-python-solution | class Solution(object):
def getBiggestThree(self, grid):
def calc(l,r,u,d):
ssum=0
expand=True
c1=c2=(l+r)//2
for row in range(u,d+1):
if c1==c2:
ssum+=grid[row][c1]
else :
ss... | get-biggest-three-rhombus-sums-in-a-grid | 1878. Get Biggest Three Rhombus Sums in a Grid || python solution | aayush_chhabra | 1 | 511 | get biggest three rhombus sums in a grid | 1,878 | 0.464 | Medium | 26,648 |
https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/discuss/1463534/Python3-Passes-116117-cases-please-help | class Solution:
def getBiggestThree(self, grid: List[List[int]]) -> List[int]:
run = set()
n = len(grid)
m = len(grid[0])
# Loop through every grid item
for i in range(n):
for j in range(m):
# Calculate the max rhombus around the current g... | get-biggest-three-rhombus-sums-in-a-grid | Python3 Passes 116/117 cases, please help | walshyb | 0 | 290 | get biggest three rhombus sums in a grid | 1,878 | 0.464 | Medium | 26,649 |
https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/discuss/1239060/Python3-prefix-sums | class Solution:
def getBiggestThree(self, grid: List[List[int]]) -> List[int]:
m, n = len(grid), len(grid[0]) # dimensions
anti, diag = {}, {}
for i in range(m):
for j in range(n):
key = i+j
if key not in anti: anti[key] = [0]
ant... | get-biggest-three-rhombus-sums-in-a-grid | [Python3] prefix sums | ye15 | 0 | 111 | get biggest three rhombus sums in a grid | 1,878 | 0.464 | Medium | 26,650 |
https://leetcode.com/problems/minimum-xor-sum-of-two-arrays/discuss/1238641/Bit-Mask | class Solution:
def minimumXORSum(self, a: List[int], b: List[int]) -> int:
@cache
def dp(mask: int) -> int:
i = bin(mask).count("1")
if i >= len(a):
return 0
return min((a[i] ^ b[j]) + dp(mask + (1 << j))
for j in range(len... | minimum-xor-sum-of-two-arrays | Bit Mask | votrubac | 103 | 6,400 | minimum xor sum of two arrays | 1,879 | 0.448 | Hard | 26,651 |
https://leetcode.com/problems/minimum-xor-sum-of-two-arrays/discuss/1239072/Python3-bit-mask-dp | class Solution:
def minimumXORSum(self, nums1: List[int], nums2: List[int]) -> int:
n = len(nums1)
@cache
def fn(mask, k):
"""Return min xor sum."""
if not mask: return 0
ans = inf
for i in range(n):
if mask & ... | minimum-xor-sum-of-two-arrays | [Python3] bit-mask dp | ye15 | 1 | 60 | minimum xor sum of two arrays | 1,879 | 0.448 | Hard | 26,652 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1241968/Minus-49 | class Solution:
def isSumEqual(self, first: str, second: str, target: str) -> bool:
def op(s: str): return "".join(chr(ord(ch) - 49) for ch in s)
return int(op(first)) + int(op(second)) == int(op(target)) | check-if-word-equals-summation-of-two-words | Minus 49 | votrubac | 18 | 1,200 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,653 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1241973/Python3-or-Time%3A-O(n)-or-Space%3A-O(1)-or-Clear.-Explanation! | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
mapping = {
'a':'0', 'b':'1', 'c':'2', 'd':'3', 'e':'4', 'f':'5', 'g':'6', 'h':'7', 'i':'8', 'j':'9'
}
def decoding(s):
nonlocal mapping
return int(''.... | check-if-word-equals-summation-of-two-words | Python3 | Time: O(n) | Space: O(1) | Clear. Explanation! | antonyakovlev | 9 | 683 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,654 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1239984/Python-oror-simple-using-ascii-conversion | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
a, b, c = [],[],[]
a_,b_,c_="","",""
base = ord("a")
def getList(l,s):
for i in s:
l.append(ord(i)-base)
return l
def getS... | check-if-word-equals-summation-of-two-words | Python || simple using ascii conversion | harshhx | 4 | 492 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,655 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1357032/Easy-Python-Solutions-(3-Approaches-Speed-98-Memory-100) | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
target_val = 0
temp = ""
for i in targetWord:
temp += str(alphabets.index(i))
target_val = int(temp)
... | check-if-word-equals-summation-of-two-words | Easy Python Solutions (3 Approaches - Speed 98%, Memory 100%) | the_sky_high | 3 | 108 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,656 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1357032/Easy-Python-Solutions-(3-Approaches-Speed-98-Memory-100) | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
target_val = 0
temp = ""
for i in targetWord:
temp += str(alphabets.index(i))
target_val = int(temp)
... | check-if-word-equals-summation-of-two-words | Easy Python Solutions (3 Approaches - Speed 98%, Memory 100%) | the_sky_high | 3 | 108 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,657 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1357032/Easy-Python-Solutions-(3-Approaches-Speed-98-Memory-100) | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
alphabets = {'a': '0', 'b': '1', 'c': '2', 'd': '3', 'e': '4', 'f': '5', 'g': '6', 'h': '7', 'i': '8', 'j': '9'}
target_val = 0
temp = ""
for i in targetWord:
temp += alphabe... | check-if-word-equals-summation-of-two-words | Easy Python Solutions (3 Approaches - Speed 98%, Memory 100%) | the_sky_high | 3 | 108 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,658 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2186388/Check-if-Word-Equals-Summation-of-Two-Words | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
wordList = [firstWord, secondWord, targetWord]
sumList = []
for word in wordList:
sumList.append(self.calcSum(word))
return sumList[0]+sumList[1]==sumList[2]
def calcSum(se... | check-if-word-equals-summation-of-two-words | Check if Word Equals Summation of Two Words | pratik_patra | 1 | 31 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,659 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1791063/Simple-python3-solution-or-82-faster-or-Easy-to-understand | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
s = "abcdefghij"
fir = str()
sec = str()
tar = str()
for i in firstWord:
fir += str(s.index(i))
for i in secondWord:
sec += str(s.index(i))
... | check-if-word-equals-summation-of-two-words | Simple python3 solution | 82% faster | Easy to understand | Coding_Tan3 | 1 | 36 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,660 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1698961/inner-function-based | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
def get_number(s):
num = 0
for c in s:
num = num * 10 + ord(c) - ord('a')
return num
return get_number(firstWord) + get_number(secondWord) == get_numb... | check-if-word-equals-summation-of-two-words | inner function based | snagsbybalin | 1 | 17 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,661 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1266027/Python3-O(mn)-time-O(1)-space | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
dictionary = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
firstWordConvert, secondWordConvert, targetWordConvert = '', '', ''
for lette... | check-if-word-equals-summation-of-two-words | Python3 O(mn) time O(1) space | peterhwang | 1 | 157 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,662 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2825043/Python-Simple-Solution | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
sum1 = ""
for i in range(0, len(firstWord)):
if firstWord[i] == 'a':
if sum1 != "0":
sum1 += str(ord(firstWord[i]) - 97)
else:
s... | check-if-word-equals-summation-of-two-words | Python Simple Solution | PranavBhatt | 0 | 1 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,663 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2812302/Python-or-simple-solution | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
def encode(s):
return int("".join([str(ord(char) - 97) for char in s]))
return encode(firstWord) + encode(secondWord) == encode(targetWord) | check-if-word-equals-summation-of-two-words | Python | simple solution | kawamataryo | 0 | 1 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,664 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2773715/Python-or-LeetCode-or-1880.-Check-if-Word-Equals-Summation-of-Two-Words | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
map1 = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7, 'i':8, 'j':9}
s1 = ""
s2 = ""
s3 = ""
for i in firstWord:
s1 += str(map1[i])
for j in secondWord... | check-if-word-equals-summation-of-two-words | Python | LeetCode | 1880. Check if Word Equals Summation of Two Words | UzbekDasturchisiman | 0 | 1 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,665 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2773715/Python-or-LeetCode-or-1880.-Check-if-Word-Equals-Summation-of-Two-Words | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
firstNum, secondNum, targetNum = "", "", ""
for char in firstWord:
firstNum += str(ord(char) - ord('a'))
for char in secondWord:
secondNum += str(ord(char) - ord... | check-if-word-equals-summation-of-two-words | Python | LeetCode | 1880. Check if Word Equals Summation of Two Words | UzbekDasturchisiman | 0 | 1 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,666 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2773715/Python-or-LeetCode-or-1880.-Check-if-Word-Equals-Summation-of-Two-Words | class Solution:
def f(self, word: str) -> int:
wordNum = ""
for i in word:
wordNum += str(ord(i) - ord('a'))
return int(wordNum)
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
return self.f(firstWord) + self.f(secondWord) == self.... | check-if-word-equals-summation-of-two-words | Python | LeetCode | 1880. Check if Word Equals Summation of Two Words | UzbekDasturchisiman | 0 | 1 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,667 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2710939/Python-oror-Simple-Approach-using-dictionary-oror-Beats-88 | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
v={'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9}
l=[]
l1=[]
l2=[]
for i in firstWord:
l.append(v.get(i))
for i in secondWord:
l1.appe... | check-if-word-equals-summation-of-two-words | Python || Simple Approach using dictionary || Beats 88% | shivammenda2002 | 0 | 4 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,668 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2609661/Solution | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
fn=fs=tw = ""
for i in range(len(firstWord)):
fn += str(ord(firstWord[i])-97)
for j in range(len(secondWord)):
fs += str(ord(secondWord[j])-97)
for k in range(len(t... | check-if-word-equals-summation-of-two-words | Solution | fiqbal997 | 0 | 8 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,669 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2520949/Easy-Python-Solution-for-Beginners | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
#Creating a map to convert alphabets to numbers
dicAlpha = {
'a':'0','b':'1','c':'2','d':'3','e':'4','f':'5','g':'6','h':'7','i':'8','j':'9'
}
newFirstWord = ""
... | check-if-word-equals-summation-of-two-words | Easy Python Solution for Beginners | Ron99 | 0 | 23 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,670 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2324275/Python-Simple | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
num1 = ''
num2 = ''
for i in firstWord:
num1+=str(ord(i)-ord('a'))
for i in secondWord:
num2+=str(ord(i)-ord('a'))
target=''... | check-if-word-equals-summation-of-two-words | Python Simple | sunakshi132 | 0 | 17 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,671 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2298827/PYTHON-oror-FAASTER-THAN-88-oror-SPACE-LESS-THAN-93oror-BASIC | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
def num(a):
n=0
for f in a:
n=n*10 +(ord(f)-97)
return n
if num(targetWord)==num(firstWord)+num(secondWord):
return(True)
else:
return... | check-if-word-equals-summation-of-two-words | PYTHON || FAASTER THAN 88% || SPACE LESS THAN 93%|| BASIC | vatsalg2002 | 0 | 12 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,672 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2215263/MINUS-97 | '''class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
ans=False
first=''
second=''
target=''
for i in firstWord:
first=first+str(ord(i)-97)
for i in secondWord:
second=second+str(ord(i)-97)
for i in targetWord:
target=target+str(ord(i)-97)
add=int(f... | check-if-word-equals-summation-of-two-words | MINUS 97 | keertika27 | 0 | 10 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,673 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2152519/Python-or-Very-Easy-elegant-and-intuitive-approach-using-cashing | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
table = {'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9}
num1 = 0
for i in firstWord:
num1 = num1 * 10 + table[i]
# print(num1)
num2 = 0... | check-if-word-equals-summation-of-two-words | Python | Very Easy, elegant and intuitive approach using cashing | __Asrar | 0 | 30 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,674 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/2045091/Python-simple-solution | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
def convert_word(word):
from string import ascii_lowercase as al
converted = ''
for i in word:
converted += str(al.index(i))
return int(converted)
... | check-if-word-equals-summation-of-two-words | Python simple solution | StikS32 | 0 | 24 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,675 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1942280/Python-Clean-and-Simple-%2B-One-Liner | class Solution:
def isSumEqual(self, w1, w2, target):
def val(w): return int("".join([str(ord(c)-ord("a")) for c in w]))
return val(w1)+val(w2) == val(target) | check-if-word-equals-summation-of-two-words | Python - Clean and Simple + One-Liner | domthedeveloper | 0 | 41 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,676 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1942280/Python-Clean-and-Simple-%2B-One-Liner | class Solution:
def isSumEqual(self, w1, w2, target):
return (lambda val : val(w1)+val(w2) == val(target))(lambda w : int("".join([str(ord(c)-ord("a")) for c in w]))) | check-if-word-equals-summation-of-two-words | Python - Clean and Simple + One-Liner | domthedeveloper | 0 | 41 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,677 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1887290/Python-one-liner-with-memory-usage-less-than-82 | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
return int(''.join(str(ord(x)-97) for x in firstWord)) + int(''.join(str(ord(x)-97) for x in secondWord)) == int(''.join(str(ord(x)-97) for x in targetWord)) | check-if-word-equals-summation-of-two-words | Python one liner with memory usage less than 82% | alishak1999 | 0 | 39 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,678 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1868904/Python-dollarolution | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
s, count = '', 0
for i in firstWord:
s += str(ord(i)-97)
count += int(s)
s = ''
for i in secondWord:
s += str(ord(i)-97)
count += int(s)
s =... | check-if-word-equals-summation-of-two-words | Python $olution | AakRay | 0 | 33 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,679 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1849669/python3orsimpleorshortorO(N)or | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
int_str = lambda s: int(''.join([str(ord(letter) - ord('a')) for letter in s]))
return int_str(firstWord) + int_str(secondWord) == int_str(targetWord) | check-if-word-equals-summation-of-two-words | python3|simple|short|O(N)|🐍🐍 | YaBhiThikHai | 0 | 29 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,680 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1846959/Easiest-Python3-Solution-oror-100-Faster-oror-Easy-to-understand-Python-code | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
x=0
y=0
z=0
valueAlpha=0
alpha=""
for i in firstWord:
alpha=i
valueAlpha=ord(alpha)-97
x=x*10+valueAlpha
for i in secondWord:
... | check-if-word-equals-summation-of-two-words | Easiest Python3 Solution || 100% Faster || Easy to understand Python code | RatnaPriya | 0 | 36 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,681 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1718566/python3-or-one-line-solution-or-faster-than-71.43 | class Solution:
def generate_num(self, words) -> int:
return int("".join([str(ord(l) % 97) for l in words]))
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
return (self.generate_num(firstWord) + self.generate_num(secondWord)) == self.generate_num(targetWord) | check-if-word-equals-summation-of-two-words | python3 | one line solution | faster than 71.43% | khalidhassan3011 | 0 | 43 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,682 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1534691/String-translate-method-90-speed | class Solution:
d = {97 + i: 48 + i for i in range(10)}
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
return (int(firstWord.translate(Solution.d)) +
int(secondWord.translate(Solution.d)) ==
int(targetWord.translate(Solution.d))) | check-if-word-equals-summation-of-two-words | String translate method, 90% speed | EvgenySH | 0 | 65 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,683 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1503964/3-line-solution-wo-explicit-type-casting-in-Python | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
a = ord('a')
to_num = lambda s: sum((ord(c) - a) * (10 ** i) for i, c in enumerate(reversed(s)))
return sum(map(to_num, (firstWord, secondWord))) == to_num(targetWord) | check-if-word-equals-summation-of-two-words | 3-line solution w/o explicit type-casting in Python | mousun224 | 0 | 53 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,684 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1496330/Python-Unicode | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
first, second, target_tot = 0, 0, 0
for fw in firstWord:
first = first * 10 + (ord(fw) - ord('a'))
for sw in secondWord:
second = second * 10 + (ord(sw) - ord('a'))
... | check-if-word-equals-summation-of-two-words | Python Unicode | jlee9077 | 0 | 60 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,685 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1406726/Python3-Faster-then-84-of-the-Solutions | class Solution:
def convert(self,s):
x = ''
for i in s:
x = x + str(ord(i)-97)
return int(x)
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
return self.convert(firstWord)+self.convert(secondWord)==self.convert(targetWord) | check-if-word-equals-summation-of-two-words | Python3 - Faster then 84% of the Solutions | harshitgupta323 | 0 | 78 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,686 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1302642/Python3-Simple-solution-beats-97-of-the-submissions | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
charMap = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4 , 'f': 5, 'g': 6, 'h': 7, 'i':8, 'j': 9}
firstWordMap = ''.join([ str(charMap[x]) for x in firstWord ])
secondWordMap = ''.join( [ str(charMap[x])... | check-if-word-equals-summation-of-two-words | [Python3] Simple solution, beats 97% of the submissions | GauravKK08 | 0 | 38 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,687 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1281996/Python-Simple | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
return self.word_to_int(firstWord) + self.word_to_int(secondWord) == self.word_to_int(targetWord)
def word_to_int(self, s):
return int(''.join(str(ord(char) - 97)
... | check-if-word-equals-summation-of-two-words | Python Simple | peatear-anthony | 0 | 72 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,688 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1275996/Python-3-one-liner!-Use-ord-function(28-ms-faster-than-91.33) | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
return (int("".join([str(ord(i)-97) for i in firstWord]))+int("".join([str(ord(i)-97) for i in secondWord]))) == int("".join([str(ord(i)-97) for i in targetWord])) | check-if-word-equals-summation-of-two-words | Python 3 one liner! Use ord function(28 ms, faster than 91.33%) | lin11116459 | 0 | 45 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,689 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1275996/Python-3-one-liner!-Use-ord-function(28-ms-faster-than-91.33) | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
a=int("".join([str(ord(i)-97) for i in firstWord]))
b=int("".join([str(ord(i)-97) for i in secondWord]))
c=int("".join([str(ord(i)-97) for i in targetWord]))
return (a+b) == c | check-if-word-equals-summation-of-two-words | Python 3 one liner! Use ord function(28 ms, faster than 91.33%) | lin11116459 | 0 | 45 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,690 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1266966/Easy-and-Efficient-Python-Solution | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
li = [chr(i) for i in range(97, 107)]
def calculate(word):
ans = ''
for i in word:
ans += str(li.index(i))
return int(ans)
sum1 = calculate(firstWord)
sum2 = calculate(secondWord)
sum3 = calculate(t... | check-if-word-equals-summation-of-two-words | Easy & Efficient Python Solution | sanu2sid | 0 | 81 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,691 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1265351/or-Python-or-Solution-using-String-Methods | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
words = [firstWord, secondWord, targetWord]
for i in range(len(words)):
convert = words[i].maketrans('abcdefghij', '0123456789')
words[i] = words[i].translate(convert)
... | check-if-word-equals-summation-of-two-words | | Python | Solution using String Methods | bruadarach | 0 | 46 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,692 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1260062/Python-Solutions-and-Explanations-Noobie-version-Equivalent-Lambda-Version-and-extra-thoughts. | class Solution(object):
def getWordValue(self, word):
""" Return a new string such that each character is represented by it's numeric counter described in the problem statement"""
newWord=''
for letter in word:
newWord+=(str(ord(letter)-97))
return newWord
def isSumEqual(self, firstWord, secondWord, tar... | check-if-word-equals-summation-of-two-words | Python Solutions & Explanations - Noobie version, Equivalent Lambda Version & extra thoughts. | antonmdv | 0 | 48 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,693 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1260062/Python-Solutions-and-Explanations-Noobie-version-Equivalent-Lambda-Version-and-extra-thoughts. | class Solution(object):
def isSumEqual(self, firstWord, secondWord, targetWord):
"""
:type firstWord: str
:type secondWord: str
:type targetWord: str
:rtype: bool
"""
numeric_value = lambda s: int(''.join([str(ord(letter)-97) for letter in s]))
return numeric_value(firstWord) + numeric_value(secondWor... | check-if-word-equals-summation-of-two-words | Python Solutions & Explanations - Noobie version, Equivalent Lambda Version & extra thoughts. | antonmdv | 0 | 48 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,694 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1259787/python-3-%3A-super-easy-solution-%3A-) | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
f = "".join([str(ord(i)-97) for i in firstWord ]) # ord("a") = 97
s = "".join([str(ord(i)-97) for i in secondWord ])
t = "".join([str(ord(i)-97) for i in targetWord ])
... | check-if-word-equals-summation-of-two-words | python 3 : super easy solution : ) | rohitkhairnar | 0 | 118 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,695 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1255097/python-3-using-ord() | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
def val(s):
res=""
for i in range(len(s)):
res+=str(ord(s[i])-ord('a'))
return int(res)
return (val(targetWord)==val(firstWord)+val(secondWord)) | check-if-word-equals-summation-of-two-words | python 3 using ord() | janhaviborde23 | 0 | 86 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,696 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1242418/Python3-easy-solution | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
s = "abcdefghij"
x1 = ''
x2 = ''
x3 = ''
for i in firstWord:
x1 += str(s.index(i))
x1 = int(x1)
for i in secondWord:
x2 += str(s.index(i))
... | check-if-word-equals-summation-of-two-words | Python3 easy solution | Sanyamx1x | 0 | 35 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,697 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1242016/Python-simple-or-Hashmap | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
memo = {'a':'0', 'b':'1', 'c':'2', 'd':'3','e':'4', 'f':'5', 'g':'6', 'h':'7', 'i':'8','j':'9'}
def manipulate(word, value):
for i in word:
value += memo[i]
return... | check-if-word-equals-summation-of-two-words | Python simple | Hashmap | dee7 | 0 | 50 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,698 |
https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/discuss/1241607/PythonPython3-solution-with-explanation | class Solution:
def isSumEqual(self, firstWord: str, secondWord: str, targetWord: str) -> bool:
alpha = 'abcdefghijklmnopqrstuvwxyz'
firstNum,secondNum,targetNum = '','',''
for i in firstWord:
firstNum += str(alpha.index(i))
for i in secondWord:
secondNum += s... | check-if-word-equals-summation-of-two-words | Python/Python3 solution with explanation | prasanthksp1009 | 0 | 74 | check if word equals summation of two words | 1,880 | 0.738 | Easy | 26,699 |
Subsets and Splits
Top 2 Solutions by Upvotes
Identifies the top 2 highest upvoted Python solutions for each problem, providing insight into popular approaches.