From 801bafd8badc65e71c280b32807f18bcdfe4b589 Mon Sep 17 00:00:00 2001 From: Vombit <45901675+Vombit@users.noreply.github.com> Date: Wed, 27 May 2026 15:52:14 +0500 Subject: [PATCH] 6 --- solutions/lc1507.py | 8 ++++++++ solutions/lc1909.py | 17 +++++++++++++++++ solutions/lc3151.py | 7 +++++++ solutions/lc557.py | 3 +++ 4 files changed, 35 insertions(+) create mode 100644 solutions/lc1507.py create mode 100644 solutions/lc1909.py create mode 100644 solutions/lc3151.py create mode 100644 solutions/lc557.py diff --git a/solutions/lc1507.py b/solutions/lc1507.py new file mode 100644 index 0000000..afdbee5 --- /dev/null +++ b/solutions/lc1507.py @@ -0,0 +1,8 @@ +class Solution: + def reformatDate(self, date: str) -> str: + month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] + + d = date.split(" ") + + return f"{d[2]}-{month.index(d[1])+1:02}-{int(d[0][:-2]):02}" diff --git a/solutions/lc1909.py b/solutions/lc1909.py new file mode 100644 index 0000000..8999875 --- /dev/null +++ b/solutions/lc1909.py @@ -0,0 +1,17 @@ +class Solution: + def canBeIncreasing(self, nums: List[int]) -> bool: + bad = 0 + for i in range(1, len(nums)): + if nums[i] <= nums[i - 1]: + bad += 1 + + if bad > 1: + return False + + l = i == 1 or nums[i] > nums[i - 2] + r = i == len(nums) - 1 or nums[i + 1] > nums[i - 1] + + if not l and not r: + return False + + return True diff --git a/solutions/lc3151.py b/solutions/lc3151.py new file mode 100644 index 0000000..3d90c80 --- /dev/null +++ b/solutions/lc3151.py @@ -0,0 +1,7 @@ +class Solution: + def isArraySpecial(self, nums: List[int]) -> bool: + for i in range(1, len(nums)): + if nums[i] % 2 == nums[i - 1] % 2: + return False + + return True diff --git a/solutions/lc557.py b/solutions/lc557.py new file mode 100644 index 0000000..0ba2951 --- /dev/null +++ b/solutions/lc557.py @@ -0,0 +1,3 @@ +class Solution: + def reverseWords(self, s: str) -> str: + return " ".join(i[::-1] for i in s.split())