diff --git a/1232/README.md b/1232/README.md new file mode 100644 index 0000000..db45f47 --- /dev/null +++ b/1232/README.md @@ -0,0 +1,3 @@ +# Hi, rahulvansh66! Here is my help . My code is on Python3 scenario + + diff --git a/1232/leetcode1232.py b/1232/leetcode1232.py new file mode 100644 index 0000000..87c2ab0 --- /dev/null +++ b/1232/leetcode1232.py @@ -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 diff --git a/394/leet394.py b/394/leet394.py new file mode 100644 index 0000000..66d87ab --- /dev/null +++ b/394/leet394.py @@ -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 diff --git a/394/readme.md b/394/readme.md new file mode 100644 index 0000000..4462edb --- /dev/null +++ b/394/readme.md @@ -0,0 +1 @@ +Hi, SpasZahariev! Here is my help . My code is on Python3 scenario . \ No newline at end of file