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/minimum-initial-energy-to-finish-tasks/discuss/944714/Python-3-or-Sort-%2B-Greedy-and-Sort-%2B-Binary-Search-or-Explanation
class Solution: def minimumEffort(self, tasks: List[List[int]]) -> int: tasks.sort(key=lambda x: x[0]-x[1]) def ok(mid): for actual, minimum in tasks: if minimum > mid or actual > mid: return False if minimum <= mid: mid -= actual return True ...
minimum-initial-energy-to-finish-tasks
Python 3 | Sort + Greedy & Sort + Binary Search | Explanation
idontknoooo
2
173
minimum initial energy to finish tasks
1,665
0.562
Hard
24,100
https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/discuss/944714/Python-3-or-Sort-%2B-Greedy-and-Sort-%2B-Binary-Search-or-Explanation
class Solution: def minimumEffort(self, tasks: List[List[int]]) -> int: tasks.sort(key=lambda x: x[0]-x[1]) ans = cur = 0 for cost, minimum in tasks: ans = min(cur-minimum, ans) cur -= cost return -ans
minimum-initial-energy-to-finish-tasks
Python 3 | Sort + Greedy & Sort + Binary Search | Explanation
idontknoooo
2
173
minimum initial energy to finish tasks
1,665
0.562
Hard
24,101
https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/discuss/2551554/Python-solution-easy-without-heap-or-binary-search-just-sorting
class Solution: def minimumEffort(self, tasks: List[List[int]]) -> int: t=tasks t.sort(key=lambda x:x[1]-x[0]) n=len(t) m=t[0][1] for i in range(n-1): m=max(m+t[i+1][0],t[i+1][1]) return m
minimum-initial-energy-to-finish-tasks
Python solution easy without heap or binary search just sorting
Gunbnelch
0
22
minimum initial energy to finish tasks
1,665
0.562
Hard
24,102
https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/discuss/2424494/Python3-or-Binary-Search-%2B-Sorting-or-With-Intuition
class Solution: def isPossible(self,time,tasks): for f,r in tasks: if time<r: return False else: time-=f return time>=0 def minimumEffort(self, tasks: List[List[int]]) -> int: tasks.sort(key=lambda x:(x[1]-x[0]),reverse=True) ...
minimum-initial-energy-to-finish-tasks
[Python3] | Binary Search + Sorting | With Intuition
swapnilsingh421
0
43
minimum initial energy to finish tasks
1,665
0.562
Hard
24,103
https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/discuss/1533683/Python3-solution-comments
class Solution: def minimumEffort(self, tasks: List[List[int]]) -> int: def cmp_items(a): #creating a custom sorting function (we want to sort by difference ~ from the biggest to the smallest) return a[0]-a[1] tasks.sort(key=cmp_items) my_energy = tasks[0][1] # how much we need...
minimum-initial-energy-to-finish-tasks
Python3 solution comments
FlorinnC1
0
65
minimum initial energy to finish tasks
1,665
0.562
Hard
24,104
https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/discuss/1145204/Python3-Simple-Solution-faster-than-100
class Solution: def minimumEffort(self, tasks: List[List[int]]) -> int: rem_energy = min_energy = sum(task[0] for task in tasks) #At first, minimum total energy=total actual energy tasks = sorted(tasks, key =lambda x:x[0]-x[1]) #Reverse sort the tasks based on the dif...
minimum-initial-energy-to-finish-tasks
Python3 Simple Solution, faster than 100%
bPapan
0
112
minimum initial energy to finish tasks
1,665
0.562
Hard
24,105
https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/discuss/1100447/Python3-sorting
class Solution: def minimumEffort(self, tasks: List[List[int]]) -> int: ans = val = 0 for x, y in sorted(tasks, key=lambda x: x[0]-x[1]): if val < y: ans += y - val val = y val -= x return ans
minimum-initial-energy-to-finish-tasks
[Python3] sorting
ye15
0
58
minimum initial energy to finish tasks
1,665
0.562
Hard
24,106
https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/discuss/1100447/Python3-sorting
class Solution: def minimumEffort(self, tasks: List[List[int]]) -> int: pq = [(x-y, y) for x, y in tasks] heapify(pq) ans = val = 0 while pq: x, y = heappop(pq) if val < y: ans += y - val val = y val -= x...
minimum-initial-energy-to-finish-tasks
[Python3] sorting
ye15
0
58
minimum initial energy to finish tasks
1,665
0.562
Hard
24,107
https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/discuss/1068459/Python3-solution-faster-than-89.86-and-less-than-89.86
class Solution: def minimumEffort(self, tasks): tasks.sort(key = lambda x:x[1]-x[0], reverse = True) energy = tasks[0][1] remain = tasks[0][1] - tasks[0][0] for cost, threshold in tasks[1:]: if remain < threshold: energy += (threshold - remain) ...
minimum-initial-energy-to-finish-tasks
Python3 solution, faster than 89.86% and less than 89.86%
danieltseng
0
100
minimum initial energy to finish tasks
1,665
0.562
Hard
24,108
https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/discuss/945060/Python-very-Concise-Solution-oror-Dhruv-Vavliya
class Solution: def minimumEffort(self, tasks: List[List[int]]) -> int: energy=0 remain=0 ar=[] for task in range(len(tasks)): ar.append((tasks[task][1]-tasks[task][0],task)) ar.sort() for task in ar[::-1]: if tasks[task[1]][1]>remain...
minimum-initial-energy-to-finish-tasks
Python -- very Concise Solution || Dhruv Vavliya
risky_coder
0
49
minimum initial energy to finish tasks
1,665
0.562
Hard
24,109
https://leetcode.com/problems/maximum-repeating-substring/discuss/1400359/Python3-Simple-Solution
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: i = 0 while word*(i+1) in sequence: i+=1 return i
maximum-repeating-substring
Python3, Simple Solution
Flerup
4
306
maximum repeating substring
1,668
0.396
Easy
24,110
https://leetcode.com/problems/maximum-repeating-substring/discuss/2192570/Python-simple-solution
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: for i in range(len(sequence)//len(word)+1,0,-1): if i*word in sequence: return i else: return 0
maximum-repeating-substring
Python simple solution
StikS32
1
134
maximum repeating substring
1,668
0.396
Easy
24,111
https://leetcode.com/problems/maximum-repeating-substring/discuss/1798591/Python3-solution-or-87-lesser-memory
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: c = 0 for i in range(1,len(sequence)//len(word)+1): if word*i in sequence: c += 1 continue break return c
maximum-repeating-substring
✔Python3 solution | 87% lesser memory
Coding_Tan3
1
203
maximum repeating substring
1,668
0.396
Easy
24,112
https://leetcode.com/problems/maximum-repeating-substring/discuss/1722457/Python-3-Short-and-Clean-using-find
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: n=len(sequence) m=len(word) c=0 for i in range(1,(n//m)+1): s=word*i if sequence.find(s)!=-1: c=i return c
maximum-repeating-substring
[Python 3] Short and Clean using find
akashmaurya001
1
95
maximum repeating substring
1,668
0.396
Easy
24,113
https://leetcode.com/problems/maximum-repeating-substring/discuss/1357665/KMP-True-O(n)
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: cnt = len(sequence)//len(word) repeat = word * cnt newstr = repeat + '#' + sequence lps = [0] maxi = 0 for i in range(1, len(newstr)): x = lps[-1] while newstr[x] != newst...
maximum-repeating-substring
KMP True O(n)
deleted_user
1
174
maximum repeating substring
1,668
0.396
Easy
24,114
https://leetcode.com/problems/maximum-repeating-substring/discuss/1260385/python3-simple-solution
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: x = 0 while True: if word*(x+1) in sequence: x += 1 else: return x
maximum-repeating-substring
python3 simple solution
EklavyaJoshi
1
131
maximum repeating substring
1,668
0.396
Easy
24,115
https://leetcode.com/problems/maximum-repeating-substring/discuss/2726421/Python3-Linear-Masochist-Solution
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: # record the index of every match using kmp # then find the longest consecutive sequence (with diff = len(word)) # this is not an easy problem def kmp_failure(p): m = len(p) f = ...
maximum-repeating-substring
[Python3] Linear Masochist Solution
rt500
0
27
maximum repeating substring
1,668
0.396
Easy
24,116
https://leetcode.com/problems/maximum-repeating-substring/discuss/2643440/4-lines-python3-solution
class Solution: def maxRepeating(self, s: str, w: str) -> int: n =len(s)//len(w) for i in range(n,-1,-1): if w*i in s: return i
maximum-repeating-substring
4 lines python3 solution
abhayCodes
0
20
maximum repeating substring
1,668
0.396
Easy
24,117
https://leetcode.com/problems/maximum-repeating-substring/discuss/2601589/python-or-explanation-in-comments
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: seq_len = len(sequence) word_len = len(word) res, i = 0, 0 # return the number of times 'word' appears in continuation from index position 'idx' def get_k_reps(idx): acc = 1 ...
maximum-repeating-substring
python | explanation in comments
sproq
0
28
maximum repeating substring
1,668
0.396
Easy
24,118
https://leetcode.com/problems/maximum-repeating-substring/discuss/2140008/Python-KMP-Simple-Solution
class Solution: def maxRepeating(self, sequence, word): maxCount_prefix = self.findMaxSubstring(word, sequence) maxCount_suffix = self.findMaxSubstring(word[::-1], sequence[::-1]) return max(maxCount_prefix, maxCount_suffix) def findMaxSubstring(self, pattern, text): ...
maximum-repeating-substring
Python - KMP Simple Solution
ErickMwazonga
0
84
maximum repeating substring
1,668
0.396
Easy
24,119
https://leetcode.com/problems/maximum-repeating-substring/discuss/2070486/Python-Two-Scans-Forward-And-Backward
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: def forward(): l, mx, current, i = len(word), 0, 0, 0 while i < len(sequence): if sequence[i : i + l] == word: current += 1 ...
maximum-repeating-substring
Python Two Scans Forward And Backward
Hejita
0
86
maximum repeating substring
1,668
0.396
Easy
24,120
https://leetcode.com/problems/maximum-repeating-substring/discuss/1483628/While-loop-96-speed
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: count = 1 while word * count in sequence: count += 1 return count - 1
maximum-repeating-substring
While loop, 96% speed
EvgenySH
0
270
maximum repeating substring
1,668
0.396
Easy
24,121
https://leetcode.com/problems/maximum-repeating-substring/discuss/1118730/Python-easy-to-understand-with-find()
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: result = 0 for i in range(1, int(len(sequence) / len(word)) + 1): if sequence.find(word * i) != -1: result += 1 else: break return result
maximum-repeating-substring
[Python] easy to understand with find()
cruim
0
184
maximum repeating substring
1,668
0.396
Easy
24,122
https://leetcode.com/problems/maximum-repeating-substring/discuss/1093627/Python3-brute-force
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: ans = 0 for k in range(101): if word*k in sequence: ans = k return ans
maximum-repeating-substring
[Python3] brute-force
ye15
0
125
maximum repeating substring
1,668
0.396
Easy
24,123
https://leetcode.com/problems/maximum-repeating-substring/discuss/1093627/Python3-brute-force
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: if len(sequence) < len(word): return 0 # edge case pattern = word * (len(sequence)//len(word)) lps = [0] k = 0 for i in range(1, len(pattern)): while k and pattern[k] != pattern[i]:...
maximum-repeating-substring
[Python3] brute-force
ye15
0
125
maximum repeating substring
1,668
0.396
Easy
24,124
https://leetcode.com/problems/maximum-repeating-substring/discuss/954431/Python-easy-and-efficient-solution
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: i = 0 n = len(word) m = len(sequence) c, k = 0, 0 # start traversing in the sequence while i < m: # if word found in sequence increase counter and increment loop by len(word) if sequence...
maximum-repeating-substring
Python easy and efficient solution
kadarsh2k00
0
272
maximum repeating substring
1,668
0.396
Easy
24,125
https://leetcode.com/problems/maximum-repeating-substring/discuss/1763973/Python-dollarolution
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: if word not in sequence: return 0 i = 1 while len(word) * i < len(sequence)+1: if word*i in sequence: i += 1 else: break return i-1
maximum-repeating-substring
Python $olution
AakRay
-1
103
maximum repeating substring
1,668
0.396
Easy
24,126
https://leetcode.com/problems/maximum-repeating-substring/discuss/1761432/Python3-92-faster
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: count = 1 while True: if (word*count in sequence): count += 1 else: return count -1
maximum-repeating-substring
Python3 92% faster
ABinfinity
-1
81
maximum repeating substring
1,668
0.396
Easy
24,127
https://leetcode.com/problems/maximum-repeating-substring/discuss/955407/Newbie-Python3-Solution-%3A-24ms
class Solution: def maxRepeating(self, sequence: str, word: str) -> int: if word in sequence: replaced = sequence.replace(word, '0') else: return 0 flag, ans = 0, 0 for char in replaced: if char == '0': flag += 1 ...
maximum-repeating-substring
[Newbie Python3 Solution : 24ms]
user6148Qk
-1
104
maximum repeating substring
1,668
0.396
Easy
24,128
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/1833998/Python3-oror-Explanation-and-Example
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: curr=list1 for count in range(b): if count==a-1: # travel to a node and --> step 1 start=curr # then save pointer in start curr=curr.next # co...
merge-in-between-linked-lists
Python3 || Explanation & Example
rushi_javiya
2
48
merge in between linked lists
1,669
0.745
Medium
24,129
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/1387631/Python3-greater85-2-Pointer-Solution.-O(N)-O(1)-Space
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: point1 = list1 point2 = list1 for _ in range(b - a): point2 = point2.next prev = None for _ in range(a): prev = point1 point1 = point1....
merge-in-between-linked-lists
[Python3] >85% 2 Pointer Solution. O(N), O(1) Space
whitehatbuds
2
185
merge in between linked lists
1,669
0.745
Medium
24,130
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/2828012/python
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: dummynode = ListNode(-1, list1) curr = dummynode idx = 0 while curr.next: if idx == a: head = curr curr = curr.next ...
merge-in-between-linked-lists
python
xy01
0
1
merge in between linked lists
1,669
0.745
Medium
24,131
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/2764595/Python3-Solution
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: temp = list1 x = None while a > 0: x = temp temp = temp.next a -= 1 temp1 = list1 while b > 0: temp1 = temp1.next ...
merge-in-between-linked-lists
Python3 Solution
mediocre-coder
0
3
merge in between linked lists
1,669
0.745
Medium
24,132
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/2597438/Python3-solution-O(N)-time-complexity-O(1)-space-complexity-99-less-memory
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: prev, first, second = None, list1, list1 #Moves the second pointer forward while b - a > 0: second = second.next b -= 1 #Moves all pointer...
merge-in-between-linked-lists
Python3 solution, O(N) time complexity, O(1) space complexity, 99% less memory
matteogianferrari
0
15
merge in between linked lists
1,669
0.745
Medium
24,133
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/2579606/Python-Readable-O(N%2BM)-pass
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: # keep the list head head = list1 # get to the first node for _ in range(a-1): list1 = list1.next # save the next node (to contin...
merge-in-between-linked-lists
[Python] - Readable O(N+M) pass
Lucew
0
13
merge in between linked lists
1,669
0.745
Medium
24,134
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/2519595/Python-or-Explained-2-pointer-Solution-or-Faster-than-99.87-or-Less-memory-than-93.79
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: l1, l2 = list1, list2 for _ in range(a - 1): l1 = l1.next temp = l1.next l1.next = list2 for _ in range(b - a + 1): temp = temp.next while l2.next: l2 = l2.next l2.next = temp return l...
merge-in-between-linked-lists
Python | Explained 2-pointer Solution | Faster than 99.87% | Less memory than 93.79%
ahmadheshamzaki
0
26
merge in between linked lists
1,669
0.745
Medium
24,135
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/2344596/Easy-python
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: #iterate on list2 to find last pointer curr=list2 while curr: if curr.next==None: last2 = curr curr=curr.next c=0 #iterate on list1 pr...
merge-in-between-linked-lists
Easy python
sunakshi132
0
15
merge in between linked lists
1,669
0.745
Medium
24,136
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/2274149/Simple-Python-Solution-Easy-to-Understand!
class Solution(object): def mergeInBetween(self, list1, indexA, indexB, list2): currentOne = temp = list1 currentTwo = list2 # find node before where A starts for _ in range(indexA-1): currentOne = currentOne.next # find node after where B e...
merge-in-between-linked-lists
Simple [Python] Solution, Easy to Understand!
ufultra
0
27
merge in between linked lists
1,669
0.745
Medium
24,137
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/1999818/python-3-oror-simple-O(b-%2B-m)-solution
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: prevA = dummy1 = ListNode(0, list1) for _ in range(a): prevA = prevA.next nextB = prevA for _ in range(b - a + 2): nextB = nextB.next ...
merge-in-between-linked-lists
python 3 || simple O(b + m) solution
dereky4
0
23
merge in between linked lists
1,669
0.745
Medium
24,138
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/1093472/Python3-2-pass
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: node = list1 for k in range(b+1): if k == a-1: start = node node = node.next end = node start.next = node = list2 while node.next: node...
merge-in-between-linked-lists
[Python3] 2-pass
ye15
0
24
merge in between linked lists
1,669
0.745
Medium
24,139
https://leetcode.com/problems/merge-in-between-linked-lists/discuss/1071317/python-3-solution-beat-74
class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: head=list1 c=0 while(c<=b): if c==a-1: prev=list1 list1=list1.next prev.next=list2 else: list1=list1...
merge-in-between-linked-lists
python 3 solution beat 74%
AchalGupta
0
58
merge in between linked lists
1,669
0.745
Medium
24,140
https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array/discuss/1543614/Python-oror-Easy-Solution
class Solution: def minimumMountainRemovals(self, lst: List[int]) -> int: l = len(lst) dp = [0] * l dp1 = [0] * l for i in range(l): # for increasing subsequence maxi = 0 for j in range(i): if lst[i] > lst[j]: if dp[j] > maxi: maxi = dp[j] dp[i] = maxi + 1 for i in range(l - 1, -...
minimum-number-of-removals-to-make-mountain-array
Python || Easy Solution
naveenrathore
2
209
minimum number of removals to make mountain array
1,671
0.425
Hard
24,141
https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array/discuss/1722955/python3%3A-TIme-Complexity-O(n2)
class Solution: def minimumMountainRemovals(self, nums: List[int]) -> int: n = len(nums) left = [0 for i in range(n)] right = [0 for i in range(n)] for i in range(1, n): val = 0 for j in range(i): if nums[j] < nums[i]: ...
minimum-number-of-removals-to-make-mountain-array
python3: TIme Complexity O(n^2)
reynaldocv
1
64
minimum number of removals to make mountain array
1,671
0.425
Hard
24,142
https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array/discuss/1093648/Python3-linearithmic-solution
class Solution: def minimumMountainRemovals(self, nums: List[int]) -> int: def fn(nums): """Return length of LIS (excluding x) ending at x.""" ans, vals = [], [] for i, x in enumerate(nums): k = bisect_left(vals, x) if k == len(v...
minimum-number-of-removals-to-make-mountain-array
[Python3] linearithmic solution
ye15
0
93
minimum number of removals to make mountain array
1,671
0.425
Hard
24,143
https://leetcode.com/problems/richest-customer-wealth/discuss/2675823/Python-or-1-liner-simple-solution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max([sum(acc) for acc in accounts])
richest-customer-wealth
Python | 1-liner simple solution
LordVader1
36
2,200
richest customer wealth
1,672
0.882
Easy
24,144
https://leetcode.com/problems/richest-customer-wealth/discuss/1077433/faster-than-98.4-submissions....python-basics
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: res=[] for i in accounts: res.append(sum(i)) return max(res) ```easy solution using python basics
richest-customer-wealth
faster than 98.4% submissions....python basics
yashwanthreddz
5
795
richest customer wealth
1,672
0.882
Easy
24,145
https://leetcode.com/problems/richest-customer-wealth/discuss/2231650/Beginner-Friendly-Solution-oror-Fast!!-oror-Python
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: # Use the variable below to remember the highest sum. wealth = 0 for customer in accounts: # The sum() function below can be replaced with another for-loop in order to traverse the nested lists. # In th...
richest-customer-wealth
Beginner Friendly Solution || Fast!! || Python
cool-huip
4
114
richest customer wealth
1,672
0.882
Easy
24,146
https://leetcode.com/problems/richest-customer-wealth/discuss/2071570/Python-Easy-Solution-oror-One-Liner
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max([sum(i) for i in accounts])
richest-customer-wealth
Python Easy Solution || One Liner
Shivam_Raj_Sharma
4
138
richest customer wealth
1,672
0.882
Easy
24,147
https://leetcode.com/problems/richest-customer-wealth/discuss/2071570/Python-Easy-Solution-oror-One-Liner
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: arr = [] for i in range(len(accounts)): wealth = 0 for j in accounts[i]: wealth += j arr.append(wealth) return max(arr)
richest-customer-wealth
Python Easy Solution || One Liner
Shivam_Raj_Sharma
4
138
richest customer wealth
1,672
0.882
Easy
24,148
https://leetcode.com/problems/richest-customer-wealth/discuss/1655228/Python-Easy-Solution-or-One-liner
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max(map(sum, accounts))
richest-customer-wealth
Python Easy Solution | One-liner ✔
leet_satyam
4
179
richest customer wealth
1,672
0.882
Easy
24,149
https://leetcode.com/problems/richest-customer-wealth/discuss/1733401/Python-3-(40ms)-or-2-Pythonic-Solutions-or-One-Liner-Easy-to-Understand
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: m=0 for i in accounts: m = max(m,sum(i)) return m
richest-customer-wealth
Python 3 (40ms) | 2 Pythonic Solutions | One-Liner Easy to Understand
MrShobhit
3
161
richest customer wealth
1,672
0.882
Easy
24,150
https://leetcode.com/problems/richest-customer-wealth/discuss/1733401/Python-3-(40ms)-or-2-Pythonic-Solutions-or-One-Liner-Easy-to-Understand
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max(map(sum,accounts))
richest-customer-wealth
Python 3 (40ms) | 2 Pythonic Solutions | One-Liner Easy to Understand
MrShobhit
3
161
richest customer wealth
1,672
0.882
Easy
24,151
https://leetcode.com/problems/richest-customer-wealth/discuss/1697292/Python-code%3A-Richest-Customer-Wealth
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: arr=[] for i in accounts: arr.append(sum(i)) return max(arr)
richest-customer-wealth
Python code: Richest Customer Wealth
Anilchouhan181
3
160
richest customer wealth
1,672
0.882
Easy
24,152
https://leetcode.com/problems/richest-customer-wealth/discuss/1154494/Python-using-sum-and-max
class Solution(object): def maximumWealth(self, accounts): """ :type accounts: List[List[int]] :rtype: int """ max_wealth = 0 for account in accounts: wealth = sum(account) max_wealth = max(wealth, max_wealth) ...
richest-customer-wealth
Python using sum and max
5tigerjelly
3
237
richest customer wealth
1,672
0.882
Easy
24,153
https://leetcode.com/problems/richest-customer-wealth/discuss/952803/Python3-1-line
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max(map(sum, accounts))
richest-customer-wealth
[Python3] 1-line
ye15
3
121
richest customer wealth
1,672
0.882
Easy
24,154
https://leetcode.com/problems/richest-customer-wealth/discuss/2361059/one-line-or-Success-Details-faster-than-100.00-or-Python3
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max([sum(i) for i in accounts])
richest-customer-wealth
one line | Success Details faster than 100.00% | Python3
vimla_kushwaha
2
94
richest customer wealth
1,672
0.882
Easy
24,155
https://leetcode.com/problems/richest-customer-wealth/discuss/2234469/Python3-simple-solution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: result = 0 for i in range(len(accounts)): result = max(result, sum(accounts[i])) return result
richest-customer-wealth
📌 Python3 simple solution
Dark_wolf_jss
2
69
richest customer wealth
1,672
0.882
Easy
24,156
https://leetcode.com/problems/richest-customer-wealth/discuss/2145674/Python-Easy-and-Simple-Solution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: maxwealth=0 for i in range(len(accounts)): maxwealth=max(sum(accounts[i]), maxwealth) return maxwealth
richest-customer-wealth
Python Easy and Simple Solution
pruthashouche
2
67
richest customer wealth
1,672
0.882
Easy
24,157
https://leetcode.com/problems/richest-customer-wealth/discuss/1312458/WEEB-DOES-PYTHON
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: cur_max = 0 for money in accounts: if sum(money) > cur_max: cur_max = sum(money) return cur_max
richest-customer-wealth
WEEB DOES PYTHON
Skywalker5423
2
118
richest customer wealth
1,672
0.882
Easy
24,158
https://leetcode.com/problems/richest-customer-wealth/discuss/1151108/Python3-Simple-Solution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: ans = 0 for i in accounts: ans = max(ans , sum(i)) return ans
richest-customer-wealth
[Python3] Simple Solution
Lolopola
2
78
richest customer wealth
1,672
0.882
Easy
24,159
https://leetcode.com/problems/richest-customer-wealth/discuss/2348319/Riches-man's-wealth-Python-simple-one
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: # Initialize the maximum wealth seen so far to 0 (the minimum wealth possible) max_wealth_so_far = 0 # Iterate over accounts for account in accounts: # Add the money in each bank ...
richest-customer-wealth
Riches man's wealth Python simple one
RohanRob
1
96
richest customer wealth
1,672
0.882
Easy
24,160
https://leetcode.com/problems/richest-customer-wealth/discuss/2328819/Python3-or-Easy-Solution-or-3-line-soution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: res = 0 temp = list(map(lambda x: sum(x), accounts)) return max(temp)
richest-customer-wealth
Python3 | Easy Solution | 3 line soution
irapandey
1
86
richest customer wealth
1,672
0.882
Easy
24,161
https://leetcode.com/problems/richest-customer-wealth/discuss/2250216/Python3-Runtime%3A-60ms-oror-Memory%3A-13.9mb-32.16
class Solution: # O(rc) || O(n) # Runtime: 60ms || Memory: 13.9mb 32.16% def maximumWealth(self, accounts: List[List[int]]) -> int: maxWealth = float('-inf') for row in range(len(accounts)): runningSum = 0 for col in range(len(accounts[row])): runningSum ...
richest-customer-wealth
Python3 Runtime: 60ms || Memory: 13.9mb 32.16%
arshergon
1
30
richest customer wealth
1,672
0.882
Easy
24,162
https://leetcode.com/problems/richest-customer-wealth/discuss/1972374/maximum-sum-easy-python3-solution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: c=0 #Intialising a counter variable for comparison for i in range(len(accounts)): #looping through the entire list of lists temp_list = accounts[i] #storing the list sum=0 for j in range(...
richest-customer-wealth
maximum sum easy python3 solution
vishwahiren16
1
72
richest customer wealth
1,672
0.882
Easy
24,163
https://leetcode.com/problems/richest-customer-wealth/discuss/1954990/Richest-customer-wealth
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: max_num = max(sum(i) for i in accounts) return max_num
richest-customer-wealth
Richest customer wealth
vidamaleki
1
29
richest customer wealth
1,672
0.882
Easy
24,164
https://leetcode.com/problems/richest-customer-wealth/discuss/1936445/Python-3-One-Liner-FASTER-THAN-988
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max(map(sum, accounts))
richest-customer-wealth
[Python 3] One-Liner, FASTER THAN 98,8%
tender777
1
50
richest customer wealth
1,672
0.882
Easy
24,165
https://leetcode.com/problems/richest-customer-wealth/discuss/1733409/Python-Easy-To-Understand-Approach-With-Explanation
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: maxWealth = 0 for money in accounts: # Finding the max value between our current max and previous max maxWealth = max(sum(money), maxWealth) return maxWealth
richest-customer-wealth
Python Easy To Understand Approach With Explanation
pniraj657
1
41
richest customer wealth
1,672
0.882
Easy
24,166
https://leetcode.com/problems/richest-customer-wealth/discuss/1717329/1672-richest-customer-wealth-or-greater-97
class Solution(object): def maximumWealth(self, accounts): """ :type accounts: List[List[int]] :rtype: int """ max_money = 0 for sbi in accounts: money = sum(sbi) if money > max_money: max_money = money return max_money
richest-customer-wealth
1672 - richest customer wealth | > 97%
ankit61d
1
51
richest customer wealth
1,672
0.882
Easy
24,167
https://leetcode.com/problems/richest-customer-wealth/discuss/1715043/1672.-Richest-Customer-Wealth-easy-python-solution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: lis=[] for x in accounts: lis.append(sum(x)) return max(lis)
richest-customer-wealth
1672. Richest Customer Wealth easy python solution
apoorv11jain
1
76
richest customer wealth
1,672
0.882
Easy
24,168
https://leetcode.com/problems/richest-customer-wealth/discuss/1450079/One-line-simple-solution-faster-than-98.42
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max([sum(acc) for acc in accounts ])
richest-customer-wealth
One line simple solution faster than 98.42%
1_d99
1
232
richest customer wealth
1,672
0.882
Easy
24,169
https://leetcode.com/problems/richest-customer-wealth/discuss/1374464/Python3-One-Liner-or-Using-map-max-sum
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max(map(sum, accounts))
richest-customer-wealth
[Python3] One Liner | Using map, max, sum
say4n
1
55
richest customer wealth
1,672
0.882
Easy
24,170
https://leetcode.com/problems/richest-customer-wealth/discuss/1172860/Simple-Python-Solutions%3A-Multiple-Approaches_O(n*m)
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: max_wealth = 0 for c in accounts: c_wealth = sum(c) if c_wealth > max_wealth: max_wealth = c_wealth return max_wealth
richest-customer-wealth
Simple Python Solutions: Multiple Approaches_O(n*m)
smaranjitghose
1
96
richest customer wealth
1,672
0.882
Easy
24,171
https://leetcode.com/problems/richest-customer-wealth/discuss/1172860/Simple-Python-Solutions%3A-Multiple-Approaches_O(n*m)
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max(map(sum,accounts))
richest-customer-wealth
Simple Python Solutions: Multiple Approaches_O(n*m)
smaranjitghose
1
96
richest customer wealth
1,672
0.882
Easy
24,172
https://leetcode.com/problems/richest-customer-wealth/discuss/1157010/Python3-one-liner-easy-and-understandable
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max([sum(i) for i in accounts])
richest-customer-wealth
Python3 one-liner easy and understandable
adarsh__kn
1
89
richest customer wealth
1,672
0.882
Easy
24,173
https://leetcode.com/problems/richest-customer-wealth/discuss/1142266/Python-99.77-faster
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: newX = 0 for x in accounts: if newX < sum(x): newX = sum(x) return newX
richest-customer-wealth
Python 99.77% faster
Valarane
1
101
richest customer wealth
1,672
0.882
Easy
24,174
https://leetcode.com/problems/richest-customer-wealth/discuss/1137766/Python3-32ms-(with-comments)
class Solution(object): def maximumWealth(self, accounts): """ :type accounts: List[List[int]] :rtype: int """ #declaring the sum of 1st list in the accounts as the biggest value result = sum(accounts[0]) #looping through each list in the accounts list for account...
richest-customer-wealth
Python3 32ms (with comments)
Akshar-code
1
112
richest customer wealth
1,672
0.882
Easy
24,175
https://leetcode.com/problems/richest-customer-wealth/discuss/2838948/Python-Fast-and-Simple-Solution
class Solution: def maximumWealth(self, accounts): richest = 0 for i in range(len(accounts)): localTotal = 0 for j in range((len(accounts[i]))): localTotal += accounts[i][j] if localTotal > richest: richest = localTotal ...
richest-customer-wealth
Python - Fast & Simple Solution
BladeStew
0
1
richest customer wealth
1,672
0.882
Easy
24,176
https://leetcode.com/problems/richest-customer-wealth/discuss/2838422/Solution-(Beginner)
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: y =[] for x in accounts: t = sum(x) y.append(t) return max(y)
richest-customer-wealth
Solution (Beginner)
arob3303
0
1
richest customer wealth
1,672
0.882
Easy
24,177
https://leetcode.com/problems/richest-customer-wealth/discuss/2828803/Python-3-lines-oror-Faster-than-97.95-and-Memory-Beats-98.38!!
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: m = 0 for a in accounts: m = max(sum(a), m) return m
richest-customer-wealth
Python 3-lines ✅✅✅ || Faster than 97.95% and Memory Beats 98.38%!!
qiy2019
0
3
richest customer wealth
1,672
0.882
Easy
24,178
https://leetcode.com/problems/richest-customer-wealth/discuss/2826236/Fast-and-Simple-Python-Solution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: reference = 0 for i in accounts: wealth = 0 for j in i: wealth += j if wealth > reference: reference = wealth return reference
richest-customer-wealth
Fast and Simple Python Solution
PranavBhatt
0
2
richest customer wealth
1,672
0.882
Easy
24,179
https://leetcode.com/problems/richest-customer-wealth/discuss/2821549/One-Liner-approach
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max(sum(i) for i in accounts)
richest-customer-wealth
One Liner approach
prathambhatiapersonal
0
3
richest customer wealth
1,672
0.882
Easy
24,180
https://leetcode.com/problems/richest-customer-wealth/discuss/2818359/The-simplest
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: result = [] for i in range(len(accounts)): result.append(sum(accounts[i])) return max(result)
richest-customer-wealth
The simplest
pkozhem
0
2
richest customer wealth
1,672
0.882
Easy
24,181
https://leetcode.com/problems/richest-customer-wealth/discuss/2810584/Easily-steps-Python3
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: wealth = 0 for i in range(len(accounts)): wealth = max(sum(accounts[i]), wealth) return wealth
richest-customer-wealth
Easily steps Python3
Ar_elazazi007
0
3
richest customer wealth
1,672
0.882
Easy
24,182
https://leetcode.com/problems/richest-customer-wealth/discuss/2805396/Pure-Algorithmic-Solution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: max = 0 # initialize the max value for i in range(len(accounts)): # loop through all of the rows sum = 0 # define and set a local running sum ...
richest-customer-wealth
Pure Algorithmic Solution
cyber-patriot517
0
3
richest customer wealth
1,672
0.882
Easy
24,183
https://leetcode.com/problems/richest-customer-wealth/discuss/2803202/Simple-and-easy-way
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: a=[] for i in accounts: a.append(sum(i)) return max(a)
richest-customer-wealth
Simple and easy way
chetan21
0
1
richest customer wealth
1,672
0.882
Easy
24,184
https://leetcode.com/problems/richest-customer-wealth/discuss/2799357/simple-solution-with-python-list-functions
class Solution: def maximumWealth(self, accounts: List[List[int]]): listout = [] for li in accounts: listout.append(sum(li)) return max(listout)
richest-customer-wealth
simple solution with python list functions
peralaarun91
0
2
richest customer wealth
1,672
0.882
Easy
24,185
https://leetcode.com/problems/richest-customer-wealth/discuss/2799356/simple-solution-with-python-list-functions
class Solution: def maximumWealth(self, accounts: List[List[int]]): listout = [] for li in accounts: listout.append(sum(li)) return max(listout)
richest-customer-wealth
simple solution with python list functions
peralaarun91
0
1
richest customer wealth
1,672
0.882
Easy
24,186
https://leetcode.com/problems/richest-customer-wealth/discuss/2788547/Python-easy-solution
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: richest = 0 for li in accounts: totalAmount = 0 for num in li: totalAmount += num if totalAmount > richest: richest = totalAmount return richest
richest-customer-wealth
Python easy solution
kamman626
0
1
richest customer wealth
1,672
0.882
Easy
24,187
https://leetcode.com/problems/richest-customer-wealth/discuss/2787219/python3-%3A-T-O(n)-S-O(1)
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: richest=0 print(len(accounts)) for i in accounts: if sum(i)>richest: richest=sum(i) return richest
richest-customer-wealth
python3 : T-O(n) , S-O(1)
fancyuserid
0
2
richest customer wealth
1,672
0.882
Easy
24,188
https://leetcode.com/problems/richest-customer-wealth/discuss/2786424/Easy-with-Python-for-the-Richest-Customer-Wealth-Task
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: return max(sum(customer_account) for customer_account in accounts)
richest-customer-wealth
Easy with Python for the Richest Customer Wealth Task
Bassel_Alf
0
2
richest customer wealth
1,672
0.882
Easy
24,189
https://leetcode.com/problems/richest-customer-wealth/discuss/2783447/Simple-Python-Solution-oror-Easy-and-Explained
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: max1 = 0 sum1 = 0 for i in accounts: sum1 = sum(i) if sum1>max1: max1 = sum1 return max1
richest-customer-wealth
Simple Python Solution || Easy & Explained
dnvavinash
0
1
richest customer wealth
1,672
0.882
Easy
24,190
https://leetcode.com/problems/richest-customer-wealth/discuss/2781059/Python3-or-Faster-than-97-or-Simple-w-less15-lines
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: most = 0 for e in accounts: current = 0 current += sum(e) if current > most: most = current else: continue return mos...
richest-customer-wealth
[Python3] | Faster than 97% | Simple w/ <15 lines
xzvg
0
4
richest customer wealth
1,672
0.882
Easy
24,191
https://leetcode.com/problems/richest-customer-wealth/discuss/2772551/Python-Brute-Force-simple-solution-for-beginners
class Solution: def maximumWealth(self, accounts: List[List[int]]) -> int: maxwealth=0 for i in range(len(accounts)): maxwealth=max(maxwealth,sum(accounts[i])) return maxwealth
richest-customer-wealth
Python Brute Force simple solution for beginners
mritunjayyy
0
2
richest customer wealth
1,672
0.882
Easy
24,192
https://leetcode.com/problems/find-the-most-competitive-subsequence/discuss/953711/Python3-greedy-O(N)
class Solution: def mostCompetitive(self, nums: List[int], k: int) -> List[int]: stack = [] # (increasing) mono-stack for i, x in enumerate(nums): while stack and stack[-1] > x and len(stack) + len(nums) - i > k: stack.pop() if len(stack) < k: stack.append(x) return...
find-the-most-competitive-subsequence
[Python3] greedy O(N)
ye15
6
342
find the most competitive subsequence
1,673
0.493
Medium
24,193
https://leetcode.com/problems/find-the-most-competitive-subsequence/discuss/953711/Python3-greedy-O(N)
class Solution: def mostCompetitive(self, nums: List[int], k: int) -> List[int]: ans, pq = [], [] prev = -inf for i, x in enumerate(nums): heappush(pq, (x, i)) if i+k >= len(nums): while pq and pq[0][1] < prev: heappop(pq) x, prev = ...
find-the-most-competitive-subsequence
[Python3] greedy O(N)
ye15
6
342
find the most competitive subsequence
1,673
0.493
Medium
24,194
https://leetcode.com/problems/find-the-most-competitive-subsequence/discuss/1027570/O(n)-time-and-O(n)-space-python3-solution-accepted-(STACK)
class Solution: def mostCompetitive(self, nums: List[int], k: int) -> List[int]: i=0 n=len(nums) res_len=0 stack=[] while(i<n): while(stack and (n-i)>k-res_len and stack[-1]>nums[i]): stack.pop() res_len-=1 else: ...
find-the-most-competitive-subsequence
O(n) time and O(n) space python3 solution accepted (STACK)
_Rehan12
2
54
find the most competitive subsequence
1,673
0.493
Medium
24,195
https://leetcode.com/problems/find-the-most-competitive-subsequence/discuss/2790817/Monotonic-Stack-Solution
class Solution: def mostCompetitive(self, nums: List[int], k: int) -> List[int]: stack,N=[],len(nums) for i,x in enumerate(nums): while(stack and stack[-1] >x and len(stack) + N-i >k ): ##put some condition on i also so that relevant length subs is formed stack.pop() ...
find-the-most-competitive-subsequence
Monotonic Stack Solution
shadowfax_1024
0
3
find the most competitive subsequence
1,673
0.493
Medium
24,196
https://leetcode.com/problems/find-the-most-competitive-subsequence/discuss/2333991/Python-monotonic-stack.-O(N)O(k)
class Solution: def mostCompetitive(self, nums: List[int], k: int) -> List[int]: stack = [] for i, n in enumerate(nums): while stack and stack[-1] > n and len(stack) + len(nums) - i > k: stack.pop() if len(stack) < k: stack.append...
find-the-most-competitive-subsequence
Python, monotonic stack. O(N)/O(k)
blue_sky5
0
33
find the most competitive subsequence
1,673
0.493
Medium
24,197
https://leetcode.com/problems/find-the-most-competitive-subsequence/discuss/1736203/Python3-or-Monotonic-Stack
class Solution: def mostCompetitive(self, nums: List[int], k: int) -> List[int]: n=len(nums) stack=[] top=0 for i in range(n): diff=n-i while stack and top+diff>k and stack[top-1]>nums[i]: stack.pop() top-=1 if top<k...
find-the-most-competitive-subsequence
[Python3] | Monotonic Stack
swapnilsingh421
0
34
find the most competitive subsequence
1,673
0.493
Medium
24,198
https://leetcode.com/problems/find-the-most-competitive-subsequence/discuss/953091/Python3-Solution-using-stack
class Solution: def __init__(self): self.stack = [] self.toRemove = 0 def mostCompetitive(self, nums: List[int], k: int) -> List[int]: self.stack.append(nums[0]) self.toRemove = len(nums) - k for i in range(1,len(nums)): while(self.stack and ...
find-the-most-competitive-subsequence
Python3 Solution using stack
swap2001
0
53
find the most competitive subsequence
1,673
0.493
Medium
24,199