Skip to content

solved #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions 1232/README.md
Original file line number Diff line number Diff 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 number Diff line number Diff 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 number Diff line number Diff 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 number Diff line number Diff line change
@@ -0,0 +1 @@
Hi, SpasZahariev! Here is my help . My code is on Python3 scenario .