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/remove-covered-intervals/discuss/1785047/Python-Simple-Python-Solution-By-Sorting-the-List
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals=sorted(intervals) i=0 while i<len(intervals)-1: a,b = intervals[i] p,q = intervals[i+1] if a <= p and q <= b: intervals.remove(intervals[i+1]) i=i-1 elif p <= a and b <= q: intervals...
remove-covered-intervals
[ Python ] ✔✔ Simple Python Solution By Sorting the List 🔥✌
ASHOK_KUMAR_MEGHVANSHI
9
677
remove covered intervals
1,288
0.572
Medium
19,100
https://leetcode.com/problems/remove-covered-intervals/discuss/1786906/Python3-oror-brute-force-40-Faster
class Solution: def removeCoveredIntervals(self, new: List[List[int]]) -> int: arr=[] for i in range(len(new)): for j in range(len(new)): if i!=j and new[j][0] <= new[i][0] and new[i][1] <= new[j][1]: arr.append(new[i]) break ...
remove-covered-intervals
Python3 || brute force - 40% Faster
Anilchouhan181
3
60
remove covered intervals
1,288
0.572
Medium
19,101
https://leetcode.com/problems/remove-covered-intervals/discuss/1786026/Python-3-(90ms)-or-Sorted-Matrix-Solution-or-Easy-to-Understand
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals = sorted(intervals, key = lambda x : (x[0], -x[1])) res = 0 ending = 0 for _, end in intervals: if end > ending: res += 1 ending = end re...
remove-covered-intervals
Python 3 (90ms) | Sorted Matrix Solution | Easy to Understand
MrShobhit
3
62
remove covered intervals
1,288
0.572
Medium
19,102
https://leetcode.com/problems/remove-covered-intervals/discuss/1786655/Python-easy-to-read-and-understand
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort(key= lambda x: (x[0], -x[1])) ans, right = 0, 0 for u, v in intervals: if v > right: ans += 1 right = max(right, v) return ans
remove-covered-intervals
Python easy to read and understand
sanial2001
1
38
remove covered intervals
1,288
0.572
Medium
19,103
https://leetcode.com/problems/remove-covered-intervals/discuss/1785717/Python-or-Sort-or-O(NlogN)-or-with-comments
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: # sort the interval by its 0th index intervals.sort() ans = 1 i = 1 curr = intervals[0] while i < len(intervals): # if [1,3] [1,5] [1,7] exists we should ideally count the...
remove-covered-intervals
Python | Sort | O(NlogN) | with comments
vishyarjun1991
1
43
remove covered intervals
1,288
0.572
Medium
19,104
https://leetcode.com/problems/remove-covered-intervals/discuss/1785678/Python-oror-Sorting-oror-98-Faster-oror-96-Space-Efficient
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: c = len(intervals) intervals.sort(key=lambda x: x[0]) x, y = intervals[0] for i in range(1, len(intervals)): if x <= intervals[i][0] and intervals[i][1] <= y: c -= 1 ...
remove-covered-intervals
Python || Sorting || 98% Faster || 96% Space Efficient
cherrysri1997
1
71
remove covered intervals
1,288
0.572
Medium
19,105
https://leetcode.com/problems/remove-covered-intervals/discuss/2749987/intuitive-solution-using-python
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort() prevStart, prevEnd = intervals[0][0], intervals[0][1] count = 0 for start, end in intervals[1:]: if prevEnd >= end or (start == prevStart and end >= prevEnd): ...
remove-covered-intervals
intuitive solution using python
nagarkarjayesh4all
0
3
remove covered intervals
1,288
0.572
Medium
19,106
https://leetcode.com/problems/remove-covered-intervals/discuss/2283574/Python-sort
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort(key=lambda interval: (interval[0], -interval[1])) removed = 0 interval = intervals[0] for ni in intervals[1:]: if ni[0] >= interval[0] and ni[1] <= interval[1]: ...
remove-covered-intervals
Python, sort
blue_sky5
0
14
remove covered intervals
1,288
0.572
Medium
19,107
https://leetcode.com/problems/remove-covered-intervals/discuss/1792078/Python3-similar-to-Merge-intervals-sorting
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: # seems like merge intervals? no, kind of but # with merge its any overlap, here covered is # c <= a and b <= d intervals.sort() # NlogN time for the sort ans = len(intervals) # at w...
remove-covered-intervals
🛳 Python3, similar to Merge intervals, sorting
normalpersontryingtopayrent
0
31
remove covered intervals
1,288
0.572
Medium
19,108
https://leetcode.com/problems/remove-covered-intervals/discuss/1787021/Python-Solution-using-iteration
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: uncovered_internals = len(intervals) for i in range(len(intervals)): for j in range(len(intervals)): if i == j: continue if intervals[i][0] >= interva...
remove-covered-intervals
Python Solution using iteration
pradeep288
0
29
remove covered intervals
1,288
0.572
Medium
19,109
https://leetcode.com/problems/remove-covered-intervals/discuss/1786579/Python-oror-Sort
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort(key = lambda x:(x[0], -x[1])) pos = 0 count = 1 for i in range(1, len(intervals)): if intervals[i][0] < intervals[pos][0] or intervals[i][1] > intervals[pos][1]: ...
remove-covered-intervals
Python || Sort
kalyan_yadav
0
20
remove covered intervals
1,288
0.572
Medium
19,110
https://leetcode.com/problems/remove-covered-intervals/discuss/1785881/fast-python-solution
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: #Time complexity: O(nlogn), Space complexity:O(1), beats 98.7% intervals.sort() res = 0 bound, pre = 0, -1 for i in intervals: if i[1]>bound: bound = i[1] ...
remove-covered-intervals
fast python solution
verySmallPotato
0
7
remove covered intervals
1,288
0.572
Medium
19,111
https://leetcode.com/problems/remove-covered-intervals/discuss/1785875/Python3-Solution-with-using-sorting
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort(key=lambda l: (l[0],-l[1])) max_right = intervals[0][1] covered_cnt = 0 for i in range(1, len(intervals)): if intervals[i][1] <= max_right: covered...
remove-covered-intervals
[Python3] Solution with using sorting
maosipov11
0
7
remove covered intervals
1,288
0.572
Medium
19,112
https://leetcode.com/problems/remove-covered-intervals/discuss/1785793/Python-or-Very-Easy-Solution
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort() index = 1 result = 0 length = len(intervals) while index < length: prev_start, prev_end = intervals[index-1][0], intervals[index-1][1] cur_start, cur_end = intervals[index][0], intervals[index][...
remove-covered-intervals
Python | Very Easy Solution
Call-Me-AJ
0
40
remove covered intervals
1,288
0.572
Medium
19,113
https://leetcode.com/problems/remove-covered-intervals/discuss/1784692/Python3-oror-Sorting-and-Set-Theory-oror-Easy-to-understand
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: n = len(intervals) ans = n intervals.sort() a = intervals[0][0] b = intervals[0][1] for i in range(1, n): if intervals[i][1] <= b: ans -= 1 ...
remove-covered-intervals
Python3 || Sorting & Set Theory || Easy to understand
sr_vrd
0
39
remove covered intervals
1,288
0.572
Medium
19,114
https://leetcode.com/problems/remove-covered-intervals/discuss/1784594/Python-3-EASY-Intuitive-Solution
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort(key=lambda x: (x[0], ~x[1])) count = 1 start, end = intervals[0] for i, j in intervals[1:]: if i >= start and j <= end: continue count += 1 ...
remove-covered-intervals
✅ [Python 3] EASY Intuitive Solution
JawadNoor
0
25
remove covered intervals
1,288
0.572
Medium
19,115
https://leetcode.com/problems/remove-covered-intervals/discuss/1784490/Python-or-sort-and-compare
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: n = len(intervals) if n == 1: return 1 intervals.sort(key = lambda x:(x[0], -x[1])) result = 1 maxRight = intervals[0][1] for i in range(1, n): ...
remove-covered-intervals
Python | sort and compare
Mikey98
0
34
remove covered intervals
1,288
0.572
Medium
19,116
https://leetcode.com/problems/remove-covered-intervals/discuss/880466/Remove-Covered-Intervals-Python3-Solution
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: toDelete=set() intervals = sorted(intervals,key=lambda x:(x[0],-x[1])) n=len(intervals) for i in range(n-1): if i in toDelete: continue ...
remove-covered-intervals
Remove Covered Intervals Python3 Solution
harshitCode13
0
44
remove covered intervals
1,288
0.572
Medium
19,117
https://leetcode.com/problems/remove-covered-intervals/discuss/879446/Python-Solution
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: count = 0 prev_interval = None # Sorting ascendingly by start value and then descendingly by end value to cover all cases for curr_interval in sorted(intervals, key=lambda x: (x[0], -x[1])): # Check if...
remove-covered-intervals
Python Solution
ehdwn1212
0
51
remove covered intervals
1,288
0.572
Medium
19,118
https://leetcode.com/problems/remove-covered-intervals/discuss/878893/Python3-O(NlogN)-Greedy-Approach-Sort-and-count-or-Easy-to-understand
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort(key=lambda x:(x[0], -x[1])) init=intervals[0] ans=1 for i in range(1,len(intervals)): if init[1]<intervals[i][1]: ans+=1 init=[min(init[0],i...
remove-covered-intervals
[Python3] O(NlogN) Greedy Approach Sort and count | Easy to understand
_vaishalijain
0
33
remove covered intervals
1,288
0.572
Medium
19,119
https://leetcode.com/problems/remove-covered-intervals/discuss/482261/Python3-Solve-with-sort
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: intervals.sort() cur_left, cur_right = intervals[0] count = 1 for interval in intervals: if cur_left == interval[0]: cur_right = interval[1] else: ...
remove-covered-intervals
Python3 Solve with sort
alanzhu_xiaozhi
0
82
remove covered intervals
1,288
0.572
Medium
19,120
https://leetcode.com/problems/remove-covered-intervals/discuss/452956/Python-3-(six-lines)
class Solution: def removeCoveredIntervals(self, I: List[List[int]]) -> int: t = 0 for (X,Y) in I: for (x,y) in I: if x<=X and Y<=y and (X,Y) != (x,y): break else: t += 1 return t - Junaid Mansuri - Chicago, IL
remove-covered-intervals
Python 3 (six lines)
junaidmansuri
0
142
remove covered intervals
1,288
0.572
Medium
19,121
https://leetcode.com/problems/remove-covered-intervals/discuss/451349/Python3-greedy
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: ans = 0 lo = hi = -1 #set anchor for x, y in sorted(intervals): if y > hi: #test for coverage if x > lo: ans += 1 lo, hi = x, y #set new anchor return a...
remove-covered-intervals
[Python3] greedy
ye15
0
69
remove covered intervals
1,288
0.572
Medium
19,122
https://leetcode.com/problems/remove-covered-intervals/discuss/451349/Python3-greedy
class Solution: def removeCoveredIntervals(self, intervals: List[List[int]]) -> int: ans, prev = 0, -inf for _, y in sorted(intervals, key=lambda x: (x[0], -x[1])): if y > prev: ans, prev = ans+1, y return ans
remove-covered-intervals
[Python3] greedy
ye15
0
69
remove covered intervals
1,288
0.572
Medium
19,123
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/1998001/Python-DP-Solution-or-Min-and-Second-min-or-Faster-than-79.77
class Solution: def minFallingPathSum(self, grid: List[List[int]]) -> int: rows = len(grid) cols = len(grid[0]) min1 = min11 = float('inf') # min1 -> minimum , min11 -> second minimum in even indexed row min2 = min22 = float('inf') # min2 -> mi...
minimum-falling-path-sum-ii
Python DP Solution | Min and Second min | Faster than 79.77%
lin_lance_07
2
148
minimum falling path sum ii
1,289
0.593
Hard
19,124
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/1577762/Simple-Python-DP-Solution-or-Time%3A-O(N2)-or-Space%3A-O(N)
class Solution: def minFallingPathSum(self, grid: List[List[int]]) -> int: # Time : O(N^2) # Space : O(N) rows = len(grid) cols = len(grid[0]) if cols == 1: return grid[0][0] dp = [float('inf') for i in range(cols + 2) ...
minimum-falling-path-sum-ii
Simple Python DP Solution | Time: O(N^2) | Space: O(N)
gangasingh1807
1
151
minimum falling path sum ii
1,289
0.593
Hard
19,125
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/451374/Python3-Bottom-up-DP
class Solution: def minFallingPathSum(self, arr: List[List[int]]) -> int: for i in range(1, len(arr)): #find 1st &amp; 2nd mininum m1 = m2 = float("inf") for x in arr[i-1]: if x < m1: m1, m2 = x, m1 elif x < m2: m2 = x ...
minimum-falling-path-sum-ii
[Python3] Bottom-up DP
ye15
1
64
minimum falling path sum ii
1,289
0.593
Hard
19,126
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/2080468/python-3-oror-dp-oror-O(n2)O(1)
class Solution: def minFallingPathSum(self, grid: List[List[int]]) -> int: n = len(grid) if n == 1: return grid[0][0] if grid[0][0] <= grid[0][1]: prevMin1, prevMin2 = 0, 1 else: prevMin1, prevMin2 = 1, 0 for j in range(2, n): ...
minimum-falling-path-sum-ii
python 3 || dp || O(n^2)/O(1)
dereky4
0
40
minimum falling path sum ii
1,289
0.593
Hard
19,127
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/2066792/Python-or-DP
class Solution: def minFallingPathSum(self, ma: List[List[int]]) -> int: n = len(ma) m = len(ma[0]) l = [] for i in range(m): l.append([ma[n-1][i],i]) l.sort() for i in range(n-2,-1,-1): t = [] for j in range(len(ma[0])): ...
minimum-falling-path-sum-ii
Python | DP
Shivamk09
0
31
minimum falling path sum ii
1,289
0.593
Hard
19,128
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/1812696/Python3-oror-DP-oror-TC%3A-O(N*N)-SC%3A-O(N*N)
class Solution: def minFallingPathSum(self, grid: List[List[int]]) -> int: n= len(grid) dp = [[0 for c in range(n)]for r in range(n)] for c in range(n): dp[0][c] = grid[0][c] for r in range(1,n): for c in range(n): #find the minimum in...
minimum-falling-path-sum-ii
Python3 || DP || TC: O(N*N), SC: O(N*N)
s_m_d_29
0
55
minimum falling path sum ii
1,289
0.593
Hard
19,129
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/1771087/Python-top-down-DP-with-time-complexity-O(N**2*log(N))-and-space-complexity-O(N)
class Solution: def minFallingPathSum(self, grid: List[List[int]]) -> int: nr = len(grid) nc = len(grid[0]) dp = grid[0] # only store the previous row # sort last row so we could choose from the minimum value directly sidx = [i[0] for i in sorted(enumerate(dp), key=l...
minimum-falling-path-sum-ii
Python top down DP with time complexity O(N**2*log(N)) and space complexity O(N)
rikku1983
0
39
minimum falling path sum ii
1,289
0.593
Hard
19,130
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/1557862/Python-and-GO-or-DP-Faster-100-or-O(1)-space-or-O(N)-time
class Solution: def minFallingPathSum(self, grid: List[List[int]]) -> int: if len(grid) == 1: return grid[0][0] minVal = 0 minPos = -1 prevMin = 0 for row in grid: # Since the maximum path sum would be 99 * 200 = 19800, set initit...
minimum-falling-path-sum-ii
Python & GO | DP Faster 100% | O(1) space | O(N) time
dartkron
0
87
minimum falling path sum ii
1,289
0.593
Hard
19,131
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/1357587/Python-3-DP-solutions-with-time-O(mn)-and-space%3A-O(n)O(1)
class Solution: def minFallingPathSum(self, arr: List[List[int]]) -> int: if not arr or not arr[0]: return 0 m, n = len(arr), len(arr[0]) if n == 1: return arr[0][0] if m == 1 else 0 dp = arr[0] prev = [x for x in dp] min1, min2 = self.find_two...
minimum-falling-path-sum-ii
Python 3 DP solutions with time O(mn) and space: O(n)/O(1)
FXSD
0
49
minimum falling path sum ii
1,289
0.593
Hard
19,132
https://leetcode.com/problems/minimum-falling-path-sum-ii/discuss/1357587/Python-3-DP-solutions-with-time-O(mn)-and-space%3A-O(n)O(1)
class Solution: def minFallingPathSum(self, arr: List[List[int]]) -> int: if not arr or not arr[0]: return 0 m, n = len(arr), len(arr[0]) if n == 1: return arr[0][0] if m == 1 else 0 dp = [[-1, 0], [-1, 0]] for i in range(m): min1, min2 = [...
minimum-falling-path-sum-ii
Python 3 DP solutions with time O(mn) and space: O(n)/O(1)
FXSD
0
49
minimum falling path sum ii
1,289
0.593
Hard
19,133
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/455239/Python-Simple.-20ms.
class Solution: def getDecimalValue(self, head: ListNode) -> int: answer = 0 while head: answer = 2*answer + head.val head = head.next return answer
convert-binary-number-in-a-linked-list-to-integer
[Python] Simple. 20ms.
rohin7
200
7,800
convert binary number in a linked list to integer
1,290
0.825
Easy
19,134
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/451811/Python3-concise-solution
class Solution: def getDecimalValue(self, head: ListNode) -> int: ans = 0 while head: ans = 2*ans + head.val head = head.next return ans
convert-binary-number-in-a-linked-list-to-integer
[Python3] concise solution
ye15
35
4,400
convert binary number in a linked list to integer
1,290
0.825
Easy
19,135
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1616498/PYTHON.-easy-and-clear-solution.
class Solution: def getDecimalValue(self, head: ListNode) -> int: res = 0 while head: res = 2*res + head.val head = head.next return res
convert-binary-number-in-a-linked-list-to-integer
PYTHON. easy & clear solution.
m-d-f
7
417
convert binary number in a linked list to integer
1,290
0.825
Easy
19,136
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1615736/Simple-5-line-solution-(Python)-time%3A-O(N)-space%3A-O(1)
class Solution: def getDecimalValue(self, head: ListNode) -> int: res = 0 while head: res = res * 2 + head.val head = head.next return res
convert-binary-number-in-a-linked-list-to-integer
Simple 5 line solution (Python) time: O(N), space: O(1)
kryuki
5
291
convert binary number in a linked list to integer
1,290
0.825
Easy
19,137
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/691292/PYTHON-EASY-28-ms-using-int(numberbase-2)
class Solution: def getDecimalValue(self, head: ListNode) -> int: binaryNumberString = "" while head: binaryNumberString += str(head.val) head = head.next return int(binaryNumberString,2)
convert-binary-number-in-a-linked-list-to-integer
[PYTHON]- EASY - 28 ms using int(number,base = 2)
amanpathak2909
4
313
convert binary number in a linked list to integer
1,290
0.825
Easy
19,138
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1369627/Python-or-Simple-or-99.54-faster
class Solution: def getDecimalValue(self, head: ListNode) -> int: ans = 0 while head: ans = 2*ans + head.val head = head.next return ans
convert-binary-number-in-a-linked-list-to-integer
Python | Simple | 99.54% faster
shraddhapp
2
170
convert binary number in a linked list to integer
1,290
0.825
Easy
19,139
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/2246470/Python3-O(N)-solution
class Solution: def getDecimalValue(self, head: ListNode) -> int: result = 0 while head: result = result * 2 + head.val head = head.next return result
convert-binary-number-in-a-linked-list-to-integer
📌 Python3 O(N) solution
Dark_wolf_jss
1
19
convert binary number in a linked list to integer
1,290
0.825
Easy
19,140
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1881639/Python-3-or-2-easy-solution-or-both-are-fastest
class Solution: def getDecimalValue(self, head: ListNode) -> int: s="" while head: s+=str(head.val) head=head.next return int(s,2)
convert-binary-number-in-a-linked-list-to-integer
Python 3 | 2 easy solution | both are fastest
Anilchouhan181
1
91
convert binary number in a linked list to integer
1,290
0.825
Easy
19,141
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1881639/Python-3-or-2-easy-solution-or-both-are-fastest
class Solution: def getDecimalValue(self, head: ListNode) -> int: ans=0 while head: ans=ans*2+head.val head=head.next return ans
convert-binary-number-in-a-linked-list-to-integer
Python 3 | 2 easy solution | both are fastest
Anilchouhan181
1
91
convert binary number in a linked list to integer
1,290
0.825
Easy
19,142
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/918976/3-Python-Solutions-Explained-(video-%2B-code)
class Solution: def getDecimalValue(self, head: ListNode) -> int: binary = "" while head: binary += str(head.val) head = head.next return int(binary, 2)
convert-binary-number-in-a-linked-list-to-integer
3 Python Solutions Explained (video + code)
spec_he123
1
84
convert binary number in a linked list to integer
1,290
0.825
Easy
19,143
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/918976/3-Python-Solutions-Explained-(video-%2B-code)
class Solution: def getDecimalValue(self, head: ListNode) -> int: res = 0 while head: res = (res << 1) | head.val head = head.next return res
convert-binary-number-in-a-linked-list-to-integer
3 Python Solutions Explained (video + code)
spec_he123
1
84
convert binary number in a linked list to integer
1,290
0.825
Easy
19,144
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/918976/3-Python-Solutions-Explained-(video-%2B-code)
class Solution: def getDecimalValue(self, head: ListNode) -> int: res = 0 while head: res = 2 * res + head.val head = head.next return res
convert-binary-number-in-a-linked-list-to-integer
3 Python Solutions Explained (video + code)
spec_he123
1
84
convert binary number in a linked list to integer
1,290
0.825
Easy
19,145
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/861521/Python3%3A-24-ms-faster-than-94.51-13.8-MB-less-than-50.89.-bit-manipulation
class Solution: def getDecimalValue(self, head: ListNode) -> int: result = 0 while(head): result <<= 1 result |= head.val head = head.next return result
convert-binary-number-in-a-linked-list-to-integer
Python3: 24 ms, faster than 94.51%, 13.8 MB, less than 50.89%. bit manipulation
Anonyknight
1
69
convert binary number in a linked list to integer
1,290
0.825
Easy
19,146
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/2456959/easy-python-code-or-linked-list
class Solution: def getDecimalValue(self, head: ListNode) -> int: x = [] output = 0 temp = head while(not temp.next==None): x.append(temp.val) temp = temp.next x.append(temp.val) j = len(x)-1 for i in x: ou...
convert-binary-number-in-a-linked-list-to-integer
easy python code | linked list
dakash682
0
30
convert binary number in a linked list to integer
1,290
0.825
Easy
19,147
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/2203140/Python-Simple-Python-Solution
class Solution: def getDecimalValue(self, head: ListNode) -> int: number = '' while head != None: number = number + str(head.val) head = head.next result = int(number,2) return result
convert-binary-number-in-a-linked-list-to-integer
[ Python ] ✅✅ Simple Python Solution 🥳✌👍
ASHOK_KUMAR_MEGHVANSHI
0
87
convert binary number in a linked list to integer
1,290
0.825
Easy
19,148
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/2171951/Python-Linked-List-Simple-Solution
class Solution: def getDecimalValue(self, head: ListNode) -> int: decimal = 0 valArr = list() temp = head while(temp): valArr.insert(0, temp.val) temp = temp.next for i in range(len(valArr)): decimal += (2**i)*valArr[i] ...
convert-binary-number-in-a-linked-list-to-integer
Python Linked List Simple Solution
kaus_rai
0
45
convert binary number in a linked list to integer
1,290
0.825
Easy
19,149
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/2155310/Faster-than-97.22-Percent-Python
class Solution: def getDecimalValue(self, head: ListNode) -> int: res = 0 while head: res = 2*res + head.val head = head.next return res
convert-binary-number-in-a-linked-list-to-integer
Faster than 97.22 Percent-Python
jayeshvarma
0
37
convert binary number in a linked list to integer
1,290
0.825
Easy
19,150
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1999081/Python-Easy-Solution-or-Optimized-or-Faster
class Solution: def getDecimalValue(self, head: ListNode) -> int: a = '' while head is not None: a += str(head.val) head = head.next return int(a, 2)
convert-binary-number-in-a-linked-list-to-integer
[Python] Easy Solution | Optimized | Faster
jamil117
0
99
convert binary number in a linked list to integer
1,290
0.825
Easy
19,151
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1986969/O(N)-or-Single-loop-or-Using-Doubling-Technique
class Solution: def getDecimalValue(self, head: ListNode) -> int: ans = 0 while head!=None: ans = (2*ans) + head.val head=head.next return ans
convert-binary-number-in-a-linked-list-to-integer
O(N) | Single loop | Using Doubling Technique
divyamohan123
0
47
convert binary number in a linked list to integer
1,290
0.825
Easy
19,152
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1978470/Python-Easy-Solution
class Solution: def getDecimalValue(self, head: ListNode) -> int: if head.val == 1 and head.next == None: return int(1) else: s = '' pt = head while pt: s += str(pt.val) pt = pt.next b = s[::-1] b...
convert-binary-number-in-a-linked-list-to-integer
[Python] Easy Solution
natscripts
0
49
convert binary number in a linked list to integer
1,290
0.825
Easy
19,153
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1953047/java-python-simple-solution-(Time-On-space-O1)
class Solution: def getDecimalValue(self, head: ListNode) -> int: length = -1 num = 0 w = head while w != None : w = w.next length += 1 mask = 1 << length w = head while w != None : if w.val == 1 : num += mask w = w.next mask >>= 1 return nu...
convert-binary-number-in-a-linked-list-to-integer
java, python - simple solution (Time On, space O1)
ZX007java
0
32
convert binary number in a linked list to integer
1,290
0.825
Easy
19,154
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1943002/Easy-Python3-Beats-99-Speed
class Solution: def getDecimalValue(self, head: ListNode) -> int: current = head s = '0b' while current: s += str(current.val) current = current.next return int(s, 2) ```
convert-binary-number-in-a-linked-list-to-integer
Easy Python3 Beats 99% Speed
aves_90
0
23
convert binary number in a linked list to integer
1,290
0.825
Easy
19,155
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1896958/Ez-oror-3-Sols-oror-beats-~88
class Solution: def getDecimalValue(self, head: ListNode) -> int: v="" while head!=None: v+=str(head.val) head=head.next return int(v, 2)
convert-binary-number-in-a-linked-list-to-integer
Ez || 3 Sols || beats ~88 %
ashu_py22
0
10
convert binary number in a linked list to integer
1,290
0.825
Easy
19,156
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1896958/Ez-oror-3-Sols-oror-beats-~88
class Solution: def getDecimalValue(self, head: ListNode) -> int: v=head.val while head.next: v= v * 2 + head.next.val head=head.next return v
convert-binary-number-in-a-linked-list-to-integer
Ez || 3 Sols || beats ~88 %
ashu_py22
0
10
convert binary number in a linked list to integer
1,290
0.825
Easy
19,157
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1896958/Ez-oror-3-Sols-oror-beats-~88
class Solution: def getDecimalValue(self, head: ListNode) -> int: v=head.val while head.next: v= (v<<1) + head.next.val head=head.next return v
convert-binary-number-in-a-linked-list-to-integer
Ez || 3 Sols || beats ~88 %
ashu_py22
0
10
convert binary number in a linked list to integer
1,290
0.825
Easy
19,158
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1800521/Python-3-Very-simple-solution-using-math-(24ms-14MB)
class Solution: def getDecimalValue(self, head: ListNode) -> int: answer = 0 while head: bit = head.val answer = (2 * answer) + bit head = head.next return answer
convert-binary-number-in-a-linked-list-to-integer
[Python 3] Very simple solution using math (24ms, 14MB)
seankala
0
61
convert binary number in a linked list to integer
1,290
0.825
Easy
19,159
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1800521/Python-3-Very-simple-solution-using-math-(24ms-14MB)
class Solution: def reverse_list(self, head: ListNode) -> ListNode: prev = None current = head while current: next_ = curr.next curr.next = prev prev = current current = next_ head = prev return head ...
convert-binary-number-in-a-linked-list-to-integer
[Python 3] Very simple solution using math (24ms, 14MB)
seankala
0
61
convert binary number in a linked list to integer
1,290
0.825
Easy
19,160
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1691267/python-solution
class Solution: def getDecimalValue(self, head: ListNode) -> int: curr = head l = [] while curr: l.append(str(curr.val)) curr = curr.next m = "".join(l) return int(m, 2)
convert-binary-number-in-a-linked-list-to-integer
python solution
Ashi_garg
0
100
convert binary number in a linked list to integer
1,290
0.825
Easy
19,161
https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/discuss/1682929/python3-simple
class Solution: def getDecimalValue(self, head: ListNode) -> int: decn = 0 while head: decn = decn*2 + head.val head = head.next return decn
convert-binary-number-in-a-linked-list-to-integer
python3 simple
snagsbybalin
0
28
convert binary number in a linked list to integer
1,290
0.825
Easy
19,162
https://leetcode.com/problems/sequential-digits/discuss/1713379/Python-3-(20ms)-or-Faster-than-95-or-Generating-All-Sequential-Digits-within-Range
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: l=len(str(low)) h=len(str(high)) ans=[] a=[12,23,34,45,56,67,78,89] t=0 while l<=h: for i in a: for j in range(0,l-2): t=i%10 ...
sequential-digits
Python 3 (20ms) | Faster than 95% | Generating All Sequential Digits within Range
MrShobhit
3
64
sequential digits
1,291
0.613
Medium
19,163
https://leetcode.com/problems/sequential-digits/discuss/853522/Python-3-or-Backtracking-DFS-or-Explanation
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: ans = [] def dfs(cur, digit): if digit <= 10 and low <= cur <= high: ans.append(cur) # add number satisfy the condition elif cur < low: pass # continue check larger...
sequential-digits
Python 3 | Backtracking, DFS | Explanation
idontknoooo
3
314
sequential digits
1,291
0.613
Medium
19,164
https://leetcode.com/problems/sequential-digits/discuss/452351/Python3%3A-Faster-than-100-less-memory-than-100
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: num = [] for x in range(1,9): while x <= high: r = x % 10 if r == 0: break if x >= low: ...
sequential-digits
Python3: Faster than 100%, less memory than 100%
whenakko
3
613
sequential digits
1,291
0.613
Medium
19,165
https://leetcode.com/problems/sequential-digits/discuss/1715565/Python-Simple-Python-Solution-!!-Using-String-Subarray
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: ans=[] s='123456789' for i in range(len(s)-1): j=2 while j<10: if int(s[i:i+j]) not in ans: if int(s[i:i+j]) in range(low,high+1): ans.append(int(s[i:i+j])) j=j+1 ans.sort() return ans
sequential-digits
[ Python ] Simple Python Solution !! Using String Subarray ✔✔
ASHOK_KUMAR_MEGHVANSHI
2
38
sequential digits
1,291
0.613
Medium
19,166
https://leetcode.com/problems/sequential-digits/discuss/1713098/Python3-simplest-and-fastest-solution-in-O(1)-with-explanation
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: # https://oeis.org/A138141 nums = (12, 23, 34, 45, 56, 67, 78, 89, 123, 234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 345678, 456789, 1234567,...
sequential-digits
[Python3] simplest and fastest solution in O(1), with explanation
modem93
2
52
sequential digits
1,291
0.613
Medium
19,167
https://leetcode.com/problems/sequential-digits/discuss/1711812/Python-oror-Simple-Approach-oror-Recursion-DP-DFS-Backtrackingoror-Easy-to-understand
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: ans=[] for i in range(1,10): temp=i for j in range(i+1,10): temp=10*temp+j if temp in range(low,high+1): ans.append(temp) ans.sort() ...
sequential-digits
Python || Simple Approach || ❌ Recursion ❌ DP ❌ DFS ❌ Backtracking|| Easy to understand
rushi_javiya
2
31
sequential digits
1,291
0.613
Medium
19,168
https://leetcode.com/problems/sequential-digits/discuss/503845/Python-Memory-Usage-Less-Than-100
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: s = "123456789" res = [] for k in range(1, len(s) + 1): for i in range(len(s) - k + 1): x = int(s[i:i+k]) if x >= low and x <= high: ...
sequential-digits
Python - Memory Usage Less Than 100%
mmbhatk
2
172
sequential digits
1,291
0.613
Medium
19,169
https://leetcode.com/problems/sequential-digits/discuss/1475845/Python3-solution
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: z = low res = [] while z <= high: x = str(z) if int(x[0]) <= 10 - len(x): c = x[0] for i in range(1,len(x)): c += str(int(x[0]) + i) ...
sequential-digits
Python3 solution
EklavyaJoshi
1
66
sequential digits
1,291
0.613
Medium
19,170
https://leetcode.com/problems/sequential-digits/discuss/1094935/Python3-Explanation-Runtime-And-Space-Analysis-O(1)-TimeSpace
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: output = [] low_str = str(low) for number_digits in range(len(low_str), len(str(high)) + 1): for start_digit in range(1, 10): number = [] if sta...
sequential-digits
[Python3] Explanation - Runtime And Space Analysis - O(1) Time/Space
numiek
1
47
sequential digits
1,291
0.613
Medium
19,171
https://leetcode.com/problems/sequential-digits/discuss/688826/Python-Simple-Hack
class Solution(object): def sequentialDigits(self, low, high): """ :type low: int :type high: int :rtype: List[int] """ res = [] nums = '123456789' min_l = len(str(low)) max_l = len(str(high)) for i in range(min_l, max_l+1): ...
sequential-digits
Python Simple Hack
Sibu0811
1
88
sequential digits
1,291
0.613
Medium
19,172
https://leetcode.com/problems/sequential-digits/discuss/451829/Python-3-(one-line)-(beats-100)
class Solution: def sequentialDigits(self, L: int, H: int) -> List[int]: return [int('123456789'[i:i+d]) for d in range(len(str(L)),len(str(H))+1) for i in range(10-d) if L <= int('123456789'[i:i+d]) <= H]
sequential-digits
Python 3 (one line) (beats 100%)
junaidmansuri
1
310
sequential digits
1,291
0.613
Medium
19,173
https://leetcode.com/problems/sequential-digits/discuss/451829/Python-3-(one-line)-(beats-100)
class Solution: def sequentialDigits(self, L: int, H: int) -> List[int]: N, DL, DH, A = '123456789', len(str(L)), len(str(H)), [] for d in range(DL,DH+1): for i in range(10-d): if L <= int(N[i:i+d]) <= H: A.append(int(N[i:i+d])) return A - Junaid Mansuri ...
sequential-digits
Python 3 (one line) (beats 100%)
junaidmansuri
1
310
sequential digits
1,291
0.613
Medium
19,174
https://leetcode.com/problems/sequential-digits/discuss/2601457/Python3-Straightforward-recursive-approach-w-comments
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: # This recursive approach will build sequential numbers, and check if they are in bound # The recursive function takes an input number # Checks if it is inbound (and not already included): and adds it to the outp...
sequential-digits
[Python3] Straightforward recursive approach w comments
connorthecrowe
0
9
sequential digits
1,291
0.613
Medium
19,175
https://leetcode.com/problems/sequential-digits/discuss/2475472/Python-runtime-64.78-memory-22.38-in-O(1)
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: ans = [] digit_len_low = len(str(low)) digit_len_high = len(str(high)) for digits in range(digit_len_low, digit_len_high+1): for start_num in range(1, 11-digits): ...
sequential-digits
Python, runtime 64.78%, memory 22.38% in O(1)
tsai00150
0
30
sequential digits
1,291
0.613
Medium
19,176
https://leetcode.com/problems/sequential-digits/discuss/2475472/Python-runtime-64.78-memory-22.38-in-O(1)
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: ans = [] nums = "123456789" digit_len_low = len(str(low)) digit_len_high = len(str(high)) for digits in range(digit_len_low, digit_len_high+1): start = 0 while start...
sequential-digits
Python, runtime 64.78%, memory 22.38% in O(1)
tsai00150
0
30
sequential digits
1,291
0.613
Medium
19,177
https://leetcode.com/problems/sequential-digits/discuss/2475472/Python-runtime-64.78-memory-22.38-in-O(1)
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: ans = [] for length in range(2, 10): for start in range(1, 11-length): cur = 0 for i in range(length-1, -1, -1): cur += (10**i) * start ...
sequential-digits
Python, runtime 64.78%, memory 22.38% in O(1)
tsai00150
0
30
sequential digits
1,291
0.613
Medium
19,178
https://leetcode.com/problems/sequential-digits/discuss/2333234/Python-easy-to-read-and-understand-or-BFS
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: q = [i+1 for i in range(9)] ans = [] while q: val = q.pop(0) if low <= val <= high: ans.append(val) last = str(val)[-1] if int(last) < 9: ...
sequential-digits
Python easy to read and understand | BFS
sanial2001
0
59
sequential digits
1,291
0.613
Medium
19,179
https://leetcode.com/problems/sequential-digits/discuss/1872824/86.06-faster-or-93.93-less-memory-or-O(10*n)-n-len(str(high))-or-sliding-window
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: #min_size is 3 for low = 100 min_size, max_size = len(str(low)), len(str(high)) res = [] seq = '123456789' for size in range(min_size, max_size + 1): for i in range...
sequential-digits
86.06% faster | 93.93% less memory | O(10*n), n =len(str(high)) | sliding window
aamir1412
0
35
sequential digits
1,291
0.613
Medium
19,180
https://leetcode.com/problems/sequential-digits/discuss/1727627/Python-3-easiest-solution
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: nums = [12, 23, 34, 45, 56, 67, 78, 89, 123, 234, 345, 456, 567, 678, 789, 1234, 2345, 3456, 4567, 5678, 6789, 12345, 23456, 34567, 45678, 56789, 123456, 234567, 3456...
sequential-digits
Python 3, easiest solution
dereky4
0
76
sequential digits
1,291
0.613
Medium
19,181
https://leetcode.com/problems/sequential-digits/discuss/1713115/Python3-24ms-solution-using-iteration
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: # first find the minimum and maximum digits possible in each combination # find the leading digit of low and high and make a string of digits 1-9 # a substring of this string will be a viable combination minDig, maxDig = len...
sequential-digits
[Python3] 24ms solution using iteration
dayeem
0
15
sequential digits
1,291
0.613
Medium
19,182
https://leetcode.com/problems/sequential-digits/discuss/1712772/Python-easy-to-understand
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: pre = '123456789' dic = set() st = len(str(low)) ed = len(str(high)) s = 0 while st<=ed: temp = int(pre[s:st+s]) s += 1 if temp>=low: if t...
sequential-digits
Python easy to understand
hrithikhh86
0
32
sequential digits
1,291
0.613
Medium
19,183
https://leetcode.com/problems/sequential-digits/discuss/1712529/Python3-oror-FAST-Solution
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: l,h=len(str(low)),len(str(high)) seq=[] for i in range(l,h+1): begNum=low//10**(i-1) if i>(10-begNum): continue for j in range(begNum,10-i+1): num=0 ...
sequential-digits
[⭐️ Python3 || FAST Solution ]
alchimie54
0
8
sequential digits
1,291
0.613
Medium
19,184
https://leetcode.com/problems/sequential-digits/discuss/1712407/Python-Easy-Solution-using-Sliding-Window-Approach
class Solution: def sequentialDigits(self, l: int, h: int) -> List[int]: result = [] number = ['1','2','3','4','5','6','7','8','9'] low = len(str(l)) high = len(str(h)) while(low <= high): idx = 0 while(idx <= len(number)-low): ...
sequential-digits
Python Easy Solution using Sliding Window Approach
Madhivarman
0
17
sequential digits
1,291
0.613
Medium
19,185
https://leetcode.com/problems/sequential-digits/discuss/1712253/Easy-Python3-Observation-based-approach-(Commented)(Explained)
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: ans = [] #Initialise the ans array for i in range(2, 10): #Run a for loop to generate all the possible numbers with given condition with leng...
sequential-digits
Easy Python3 Observation based approach (Commented)(Explained)
sdasstriver9
0
15
sequential digits
1,291
0.613
Medium
19,186
https://leetcode.com/problems/sequential-digits/discuss/1711780/Python-Solution-using-BFS
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: q, res = [], [] for i in range(1, 10): q.append(i) while len(q): cur_val = q.pop() if low <= cur_val <= high: res.append(cur_val) new_...
sequential-digits
Python Solution, using BFS
pradeep288
0
18
sequential digits
1,291
0.613
Medium
19,187
https://leetcode.com/problems/sequential-digits/discuss/855427/Python3-bisect_left-Sequential-Digits
class Solution: arr = [int('123456789'[i:i+l]) for l in range(2, 10) for i in range(10-l)] def sequentialDigits(self, low: int, high: int) -> List[int]: return Solution.arr[bisect_left(Solution.arr, low): bisect_left(Solution.arr, high)]
sequential-digits
Python3 bisect_left - Sequential Digits
r0bertz
0
30
sequential digits
1,291
0.613
Medium
19,188
https://leetcode.com/problems/sequential-digits/discuss/853854/Python-Simple-solution-using-Python
class Solution(object): def sequentialDigits(self, low, high): """ :type low: int :type high: int :rtype: List[int] """ dig = '123456789' res = [] l = len(str(low)) while l <= len(str(high)): for i in range(10-l): c...
sequential-digits
[Python] Simple solution using Python
mjgallag
0
63
sequential digits
1,291
0.613
Medium
19,189
https://leetcode.com/problems/sequential-digits/discuss/477006/Python3-96.72-(20-ms)100.00-(12.8-MB)
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: ret = [] if (low <= 123456789): high = high if high < 123456789 else 123456789 starting_length = len(str(low)) ending_length = len(str(high)) + 1 for leng...
sequential-digits
Python3 96.72% (20 ms)/100.00% (12.8 MB)
numiek_p
0
69
sequential digits
1,291
0.613
Medium
19,190
https://leetcode.com/problems/sequential-digits/discuss/452417/Python-3%3A-generate-and-bisect
class Solution: def sequentialDigits(self, low: int, high: int) -> list: from bisect import bisect_left, bisect_right d = [str(i) for i in range(1,10)] def seq(n) -> int: for j in range(10 - n): yield int(''.join(d[j:j+n])) def sequential...
sequential-digits
Python 3: generate and bisect
deleted_user
0
45
sequential digits
1,291
0.613
Medium
19,191
https://leetcode.com/problems/sequential-digits/discuss/452378/Python3%3A-24ms-faster-than-100
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: res = [] length = len(str(low)) firstDigit = low // (10 ** (length - 1)) while True: num = digit = firstDigit for i in range(length - 1): digit += 1 i...
sequential-digits
Python3: 24ms, faster than 100%
andnik
0
103
sequential digits
1,291
0.613
Medium
19,192
https://leetcode.com/problems/sequential-digits/discuss/451968/Python-24ms-generate-next-sequential-integer-from-previous
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: res = [] digits = [int(x) for x in str(low)] first, length = digits[0], len(digits) if first > 10 - length: first = 1 length += 1 power = 10**(lengt...
sequential-digits
Python 24ms, generate next sequential integer from previous
shigatan
0
68
sequential digits
1,291
0.613
Medium
19,193
https://leetcode.com/problems/sequential-digits/discuss/451865/Python3-directly-generate-integers-with-sequential-digits
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: digits = "123456789" def fn(n): if n > 9: return [] #cap lo = int(digits[:n]) hi = int(digits[-n:]) return range(lo, hi+1, int("1"*n)) lo, hi = len...
sequential-digits
[Python3] directly generate integers with sequential digits
ye15
0
93
sequential digits
1,291
0.613
Medium
19,194
https://leetcode.com/problems/sequential-digits/discuss/451865/Python3-directly-generate-integers-with-sequential-digits
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: ans = [] for x in range(1, 10): val = 0 for d in range(x, 10): val = 10*val + d if low <= val <= high: ans.append(val) return sorted(ans)
sequential-digits
[Python3] directly generate integers with sequential digits
ye15
0
93
sequential digits
1,291
0.613
Medium
19,195
https://leetcode.com/problems/sequential-digits/discuss/1711650/Explained-Solution-Using-hints-Python3!
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: possibilities = [ 12, 23, 34, 45, 56, 67, 78, 89, 123, 234, 345, 456, 567,...
sequential-digits
Explained Solution Using hints - Python3!
kindahodor
-1
19
sequential digits
1,291
0.613
Medium
19,196
https://leetcode.com/problems/sequential-digits/discuss/1377826/Python-or-Recursive-or-Faster-Than-95-or-Beginner-Friendly
class Solution: def sequentialDigits(self, low: int, high: int) -> List[int]: def recur(number, ans): intNum = int(number) if intNum >= low and intNum <= high: ans.append(intNum) if number[-1] != '9': recur( number + str( int(number[-1])+1 ), ans) ...
sequential-digits
Python | Recursive | Faster Than 95% | Beginner Friendly
paramvs8
-1
95
sequential digits
1,291
0.613
Medium
19,197
https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/discuss/691648/Python3-binary-search-like-bisect_right-Maximum-Side-Length-of-a-Square-with-Sum-less-Threshold
class Solution: def maxSideLength(self, mat: List[List[int]], threshold: int) -> int: ans = 0 m = len(mat) n = len(mat[0]) presum = [[0] * (n+1) for _ in range(m+1)] for i in range(1, m+1): for j in range(1, n+1): presum[i][j] = mat[i-1...
maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold
Python3 binary search like bisect_right - Maximum Side Length of a Square with Sum <= Threshold
r0bertz
1
165
maximum side length of a square with sum less than or equal to threshold
1,292
0.532
Medium
19,198
https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/discuss/691648/Python3-binary-search-like-bisect_right-Maximum-Side-Length-of-a-Square-with-Sum-less-Threshold
class Solution: def maxSideLength(self, mat: List[List[int]], threshold: int) -> int: m = len(mat) n = len(mat[0]) presum = [[0] * (n+1) for _ in range(m+1)] for i in range(1, m+1): for j in range(1, n+1): presum[i][j] = mat[i-1][j-1] + presum[i][j-1] + pr...
maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold
Python3 binary search like bisect_right - Maximum Side Length of a Square with Sum <= Threshold
r0bertz
1
165
maximum side length of a square with sum less than or equal to threshold
1,292
0.532
Medium
19,199