Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions 1232/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
# Hi, rahulvansh66! Here is my help . My code is on Python3 scenario


6 changes: 6 additions & 0 deletions 1232/leetcode1232.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
from typing import List
class Solution:
def checkStraightLine(self, coords: List[List[int]]) -> bool:
if len(set(x for x, y in coords)) == 1: return True
if len(set(x for x, y in coords)) < len(coords): return False
return len(set((p1[1] - p2[1])/(p1[0] - p2[0]) for p1, p2 in zip(coords, coords[1:]))) == 1
33 changes: 33 additions & 0 deletions 394/leet394.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
class Solution:
def decodeString(self, s: str) -> str:
## assuming a valid string is provided s != ("1[a", "2[[2ac]]")
def get_char():
res = ""
while stack and not stack[-1] == '[':
res = stack.pop() + res
return res

def get_num():
num = ""
while stack and stack[-1].isdigit():
num = stack.pop() + num
return num

final= ""
stack = []
for ele in s:
if ele == "]": # pop routine
res = get_char()
stack.pop() # removing the "[" bracket
num = get_num()
if num:
res = int(num) * res
if stack == []:
final += res
else:
stack.append(res)
else:
stack.append(ele)
if stack:
final += ''.join(stack)
return final
1 change: 1 addition & 0 deletions 394/readme.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Hi, SpasZahariev! Here is my help . My code is on Python3 scenario .