From abd8af34237cd71a5a3cda1a24124d00bcae6c14 Mon Sep 17 00:00:00 2001
From: Valentyn Kolesnikov <javadev75@gmail.com>
Date: Sun, 16 Jun 2024 03:42:53 +0300
Subject: [PATCH] Improved readmes

---
 .../python/g0001_0100/s0001_two_sum/readme.md | 16 +-------
 .../s0002_add_two_numbers/readme.md           | 34 +---------------
 .../readme.md                                 | 28 +------------
 .../readme.md                                 | 34 +---------------
 .../readme.md                                 | 40 +------------------
 .../s0006_zigzag_conversion/readme.md         | 31 +-------------
 .../s0007_reverse_integer/readme.md           | 23 +----------
 .../s0008_string_to_integer_atoi/readme.md    | 35 +---------------
 .../s0009_palindrome_number/readme.md         | 10 +----
 .../readme.md                                 | 31 +-------------
 .../s0011_container_with_most_water/readme.md | 20 +---------
 .../python/g0001_0100/s0015_3sum/readme.md    | 39 +-----------------
 .../readme.md                                 | 28 +------------
 .../readme.md                                 | 28 +------------
 .../s0020_valid_parentheses/readme.md         | 22 +---------
 .../s0021_merge_two_sorted_lists/readme.md    | 34 +---------------
 .../s0022_generate_parentheses/readme.md      | 25 +-----------
 .../s0056_merge_intervals/readme.md           | 15 -------
 18 files changed, 17 insertions(+), 476 deletions(-)

diff --git a/src/main/python/g0001_0100/s0001_two_sum/readme.md b/src/main/python/g0001_0100/s0001_two_sum/readme.md
index 1e1f5e6..c489a63 100644
--- a/src/main/python/g0001_0100/s0001_two_sum/readme.md
+++ b/src/main/python/g0001_0100/s0001_two_sum/readme.md
@@ -101,18 +101,4 @@ print(solution.twoSum(nums3, target3))  # Output: [0, 1]
 ```
 
 ### Time Complexity:
-The time complexity of this algorithm is O(n), where n is the number of elements in the array. The dictionary lookup operation is constant time.
-
-## Solution
-
-```python
-class Solution:
-    def twoSum(self, numbers: List[int], target: int) -> List[int]:
-        index_map = {}
-        for i, num in enumerate(numbers):
-            required_num = target - num
-            if required_num in index_map:
-                return [index_map[required_num], i]
-            index_map[num] = i
-        return [-1, -1]
-```
\ No newline at end of file
+The time complexity of this algorithm is O(n), where n is the number of elements in the array. The dictionary lookup operation is constant time.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0002_add_two_numbers/readme.md b/src/main/python/g0001_0100/s0002_add_two_numbers/readme.md
index c24c2aa..373dcd1 100644
--- a/src/main/python/g0001_0100/s0002_add_two_numbers/readme.md
+++ b/src/main/python/g0001_0100/s0002_add_two_numbers/readme.md
@@ -127,36 +127,4 @@ result = solution.addTwoNumbers(l1, l2)
 # Output: [8, 9, 9, 9, 0, 0, 0, 1]
 ```
 
-This code defines a `ListNode` class for the singly-linked list and a `Solution` class with a method `addTwoNumbers` that takes two linked lists as input and returns the result as a linked list. The example usage demonstrates how to create instances of the `ListNode` class and call the `addTwoNumbers` method with different inputs.
-
-## Solution
-
-```python
-# Definition for singly-linked list.
-# class ListNode:
-#     def __init__(self, val=0, next=None):
-#         self.val = val
-#         self.next = next
-class Solution:
-    def addTwoNumbers(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]:
-        dummy_head = ListNode(0)
-        p, q, curr = l1, l2, dummy_head
-        carry = 0
-        
-        while p is not None or q is not None:
-            x = p.val if p is not None else 0
-            y = q.val if q is not None else 0
-            sum = carry + x + y
-            carry = sum // 10
-            curr.next = ListNode(sum % 10)
-            curr = curr.next
-            if p is not None:
-                p = p.next
-            if q is not None:
-                q = q.next
-        
-        if carry > 0:
-            curr.next = ListNode(carry)
-        
-        return dummy_head.next
-```
\ No newline at end of file
+This code defines a `ListNode` class for the singly-linked list and a `Solution` class with a method `addTwoNumbers` that takes two linked lists as input and returns the result as a linked list. The example usage demonstrates how to create instances of the `ListNode` class and call the `addTwoNumbers` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0003_longest_substring_without_repeating_characters/readme.md b/src/main/python/g0001_0100/s0003_longest_substring_without_repeating_characters/readme.md
index 1cc659a..31e33a0 100644
--- a/src/main/python/g0001_0100/s0003_longest_substring_without_repeating_characters/readme.md
+++ b/src/main/python/g0001_0100/s0003_longest_substring_without_repeating_characters/readme.md
@@ -120,30 +120,4 @@ s4 = ""
 print(solution.lengthOfLongestSubstring(s4))  # Output: 0
 ```
 
-This code defines a `Solution` class with a method `lengthOfLongestSubstring` that takes a string `s` as input and returns the length of the longest substring without repeating characters. The example usage demonstrates how to create an instance of the `Solution` class and call the `lengthOfLongestSubstring` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def lengthOfLongestSubstring(self, s: str) -> int:
-        last_indices = [-1] * 256
-        max_len = 0
-        cur_len = 0
-        start = 0
-
-        for i, char in enumerate(s):
-            if last_indices[ord(char)] < start:
-                last_indices[ord(char)] = i
-                cur_len += 1
-            else:
-                last_index = last_indices[ord(char)]
-                start = last_index + 1
-                cur_len = i - start + 1
-                last_indices[ord(char)] = i
-
-            if cur_len > max_len:
-                max_len = cur_len
-
-        return max_len
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `lengthOfLongestSubstring` that takes a string `s` as input and returns the length of the longest substring without repeating characters. The example usage demonstrates how to create an instance of the `Solution` class and call the `lengthOfLongestSubstring` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md b/src/main/python/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md
index ff70f23..eb74c90 100644
--- a/src/main/python/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md
+++ b/src/main/python/g0001_0100/s0004_median_of_two_sorted_arrays/readme.md
@@ -116,36 +116,4 @@ nums2_5 = []
 print(solution.findMedianSortedArrays(nums1_5, nums2_5))  # Output: 2.00000
 ```
 
-This code defines a `Solution` class with a method `findMedianSortedArrays` that takes two sorted arrays (`nums1` and `nums2`) as input and returns the median of the combined sorted array. The example usage demonstrates how to create an instance of the `Solution` class and call the `findMedianSortedArrays` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
-        if len(nums2) < len(nums1):
-            return self.findMedianSortedArrays(nums2, nums1)
-
-        n1, n2 = len(nums1), len(nums2)
-        low, high = 0, n1
-
-        while low <= high:
-            cut1 = (low + high) // 2
-            cut2 = (n1 + n2 + 1) // 2 - cut1
-
-            l1 = float('-inf') if cut1 == 0 else nums1[cut1 - 1]
-            l2 = float('-inf') if cut2 == 0 else nums2[cut2 - 1]
-            r1 = float('inf') if cut1 == n1 else nums1[cut1]
-            r2 = float('inf') if cut2 == n2 else nums2[cut2]
-
-            if l1 <= r2 and l2 <= r1:
-                if (n1 + n2) % 2 == 0:
-                    return (max(l1, l2) + min(r1, r2)) / 2.0
-                return max(l1, l2)
-            elif l1 > r2:
-                high = cut1 - 1
-            else:
-                low = cut1 + 1
-
-        return 0.0
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `findMedianSortedArrays` that takes two sorted arrays (`nums1` and `nums2`) as input and returns the median of the combined sorted array. The example usage demonstrates how to create an instance of the `Solution` class and call the `findMedianSortedArrays` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0005_longest_palindromic_substring/readme.md b/src/main/python/g0001_0100/s0005_longest_palindromic_substring/readme.md
index ee75bd7..5907ad2 100644
--- a/src/main/python/g0001_0100/s0005_longest_palindromic_substring/readme.md
+++ b/src/main/python/g0001_0100/s0005_longest_palindromic_substring/readme.md
@@ -117,42 +117,4 @@ s4 = "ac"
 print(solution.longestPalindrome(s4))  # Output: "a"
 ```
 
-This code defines a `Solution` class with a method `longestPalindrome` that takes a string `s` as input and returns the longest palindromic substring. The example usage demonstrates how to create an instance of the `Solution` class and call the `longestPalindrome` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def longestPalindrome(self, s: str) -> str:
-        # Create a new string with separators
-        new_str = ['#'] * (2 * len(s) + 1)
-        for i in range(len(s)):
-            new_str[2 * i + 1] = s[i]
-
-        dp = [0] * len(new_str)
-        friend_center = 0
-        friend_radius = 0
-        lps_center = 0
-        lps_radius = 0
-
-        for i in range(len(new_str)):
-            if friend_center + friend_radius > i:
-                dp[i] = min(dp[2 * friend_center - i], (friend_center + friend_radius) - i)
-            else:
-                dp[i] = 1
-
-            while i + dp[i] < len(new_str) and i - dp[i] >= 0 and new_str[i + dp[i]] == new_str[i - dp[i]]:
-                dp[i] += 1
-
-            if friend_center + friend_radius < i + dp[i]:
-                friend_center = i
-                friend_radius = dp[i]
-
-            if lps_radius < dp[i]:
-                lps_center = i
-                lps_radius = dp[i]
-
-        start = (lps_center - lps_radius + 1) // 2
-        end = (lps_center + lps_radius - 1) // 2
-        return s[start:end]
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `longestPalindrome` that takes a string `s` as input and returns the longest palindromic substring. The example usage demonstrates how to create an instance of the `Solution` class and call the `longestPalindrome` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0006_zigzag_conversion/readme.md b/src/main/python/g0001_0100/s0006_zigzag_conversion/readme.md
index 559b216..b43f343 100644
--- a/src/main/python/g0001_0100/s0006_zigzag_conversion/readme.md
+++ b/src/main/python/g0001_0100/s0006_zigzag_conversion/readme.md
@@ -118,33 +118,4 @@ numRows3 = 1
 print(solution.convert(s3, numRows3))  # Output: "A"
 ```
 
-This code defines a `Solution` class with a method `convert` that takes a string `s` and the number of rows `numRows` as input and returns the zigzag conversion of the string. The example usage demonstrates how to create an instance of the `Solution` class and call the `convert` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def convert(self, s: str, numRows: int) -> str:
-        s_len = len(s)
-        if numRows == 1:
-            return s
-
-        max_dist = numRows * 2 - 2
-        buf = []
-
-        for i in range(numRows):
-            index = i
-            if i == 0 or i == numRows - 1:
-                while index < s_len:
-                    buf.append(s[index])
-                    index += max_dist
-            else:
-                while index < s_len:
-                    buf.append(s[index])
-                    index += max_dist - i * 2
-                    if index >= s_len:
-                        break
-                    buf.append(s[index])
-                    index += i * 2
-        return ''.join(buf)
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `convert` that takes a string `s` and the number of rows `numRows` as input and returns the zigzag conversion of the string. The example usage demonstrates how to create an instance of the `Solution` class and call the `convert` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0007_reverse_integer/readme.md b/src/main/python/g0001_0100/s0007_reverse_integer/readme.md
index 0a58d29..597c2e5 100644
--- a/src/main/python/g0001_0100/s0007_reverse_integer/readme.md
+++ b/src/main/python/g0001_0100/s0007_reverse_integer/readme.md
@@ -124,25 +124,4 @@ x4 = 0
 print(solution.reverse(x4))  # Output: 0
 ```
 
-This code defines a `Solution` class with a method `reverse` that takes an integer `x` as input and returns the reversed integer. The example usage demonstrates how to create an instance of the `Solution` class and call the `reverse` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def reverse(self, x: int) -> int:
-        rev = 0
-        sign = -1 if x < 0 else 1
-        x = abs(x)
-
-        while x != 0:
-            rev = rev * 10 + x % 10
-            x //= 10
-
-        rev *= sign
-
-        if rev > 2**31 - 1 or rev < -2**31:
-            return 0
-
-        return rev
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `reverse` that takes an integer `x` as input and returns the reversed integer. The example usage demonstrates how to create an instance of the `Solution` class and call the `reverse` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0008_string_to_integer_atoi/readme.md b/src/main/python/g0001_0100/s0008_string_to_integer_atoi/readme.md
index e381a2c..edb248c 100644
--- a/src/main/python/g0001_0100/s0008_string_to_integer_atoi/readme.md
+++ b/src/main/python/g0001_0100/s0008_string_to_integer_atoi/readme.md
@@ -206,37 +206,4 @@ s5 = "-91283472332"
 print(solution.myAtoi(s5))  # Output: -2147483648
 ```
 
-This code defines a `Solution` class with a method `myAtoi` that takes a string `s` as input and returns the 32-bit signed integer. The example usage demonstrates how to create an instance of the `Solution` class and call the `myAtoi` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def myAtoi(self, s: str) -> int:
-        s = s.lstrip()
-        if s == '':
-            return 0
-
-        result = ''
-        i = 0
-
-        negative = False
-        if s[0] == '-':
-            negative = True
-            i += 1
-        elif s[0] == '+':
-            i += 1
-
-        while i < len(s) and s[i].isnumeric():
-            result += s[i]
-            i += 1
-
-        if result:
-            result = -1*int(result) if negative else int(result)
-            if result < -2**31:
-                return -2**31
-            elif result > 2**31 - 1:
-                return 2**31 - 1
-            return result
-        return 0
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `myAtoi` that takes a string `s` as input and returns the 32-bit signed integer. The example usage demonstrates how to create an instance of the `Solution` class and call the `myAtoi` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0009_palindrome_number/readme.md b/src/main/python/g0001_0100/s0009_palindrome_number/readme.md
index eb938c9..78135a3 100644
--- a/src/main/python/g0001_0100/s0009_palindrome_number/readme.md
+++ b/src/main/python/g0001_0100/s0009_palindrome_number/readme.md
@@ -103,12 +103,4 @@ x4 = -101
 print(solution.isPalindrome(x4))  # Output: False
 ```
 
-This code defines a `Solution` class with a method `isPalindrome` that takes an integer `x` as input and returns `True` if it is a palindrome and `False` otherwise. The example usage demonstrates how to create an instance of the `Solution` class and call the `isPalindrome` method with different inputs. The `reverse` method is used to reverse the digits of a positive integer.
-
-## Solution
-
-```python
-class Solution:
-    def isPalindrome(self, x: int) -> bool:
-        return str(x) == str(x)[::-1]
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `isPalindrome` that takes an integer `x` as input and returns `True` if it is a palindrome and `False` otherwise. The example usage demonstrates how to create an instance of the `Solution` class and call the `isPalindrome` method with different inputs. The `reverse` method is used to reverse the digits of a positive integer.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0010_regular_expression_matching/readme.md b/src/main/python/g0001_0100/s0010_regular_expression_matching/readme.md
index 0ba87fc..2e43675 100644
--- a/src/main/python/g0001_0100/s0010_regular_expression_matching/readme.md
+++ b/src/main/python/g0001_0100/s0010_regular_expression_matching/readme.md
@@ -119,33 +119,4 @@ s5, p5 = "mississippi", "mis*is*p*."
 print(solution.isMatch(s5, p5))  # Output: False
 ```
 
-This code defines a `Solution` class with a method `isMatch` that takes a string `s` and a pattern `p` as input and returns `True` if they match and `False` otherwise. The example usage demonstrates how to create an instance of the `Solution` class and call the `isMatch` method with different inputs using the recursive approach.
-
-## Solution
-
-```python
-class Solution:
-    def __init__(self):
-        self.cache = None
-
-    def isMatch(self, s: str, p: str) -> bool:
-        self.cache = [[None] * (len(p) + 1) for _ in range(len(s) + 1)]
-        return self._isMatch(s, p, 0, 0)
-
-    def _isMatch(self, s: str, p: str, i: int, j: int) -> bool:
-        if j == len(p):
-            return i == len(s)
-
-        if self.cache[i][j] is not None:
-            return self.cache[i][j]
-
-        first_match = i < len(s) and (s[i] == p[j] or p[j] == '.')
-
-        if j + 1 < len(p) and p[j + 1] == '*':
-            result = (first_match and self._isMatch(s, p, i + 1, j)) or self._isMatch(s, p, i, j + 2)
-        else:
-            result = first_match and self._isMatch(s, p, i + 1, j + 1)
-
-        self.cache[i][j] = result
-        return result
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `isMatch` that takes a string `s` and a pattern `p` as input and returns `True` if they match and `False` otherwise. The example usage demonstrates how to create an instance of the `Solution` class and call the `isMatch` method with different inputs using the recursive approach.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0011_container_with_most_water/readme.md b/src/main/python/g0001_0100/s0011_container_with_most_water/readme.md
index 3358cf4..c4ae3b8 100644
--- a/src/main/python/g0001_0100/s0011_container_with_most_water/readme.md
+++ b/src/main/python/g0001_0100/s0011_container_with_most_water/readme.md
@@ -114,22 +114,4 @@ height4 = [1, 2, 1]
 print(solution.maxArea(height4))  # Output: 2
 ```
 
-This code defines a `Solution` class with a method `maxArea` that takes an array of heights as input and returns the maximum area that can be formed by a container. The example usage demonstrates how to create an instance of the `Solution` class and call the `maxArea` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def maxArea(self, height: List[int]) -> int:
-        max_area = -1
-        left = 0
-        right = len(height) - 1
-        while left < right:
-            if height[left] < height[right]:
-                max_area = max(max_area, height[left] * (right - left))
-                left += 1
-            else:
-                max_area = max(max_area, height[right] * (right - left))
-                right -= 1
-        return max_area
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `maxArea` that takes an array of heights as input and returns the maximum area that can be formed by a container. The example usage demonstrates how to create an instance of the `Solution` class and call the `maxArea` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0015_3sum/readme.md b/src/main/python/g0001_0100/s0015_3sum/readme.md
index ba6d695..c27d3d0 100644
--- a/src/main/python/g0001_0100/s0015_3sum/readme.md
+++ b/src/main/python/g0001_0100/s0015_3sum/readme.md
@@ -121,41 +121,4 @@ nums3 = [0]
 print(solution.threeSum(nums3))  # Output: []
 ```
 
-This code defines a `Solution` class with a method `threeSum` that takes an array `nums` as input and returns a list of unique triplets whose sum is equal to zero. The example usage demonstrates how to create an instance of the `Solution` class and call the `threeSum` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def threeSum(self, nums: List[int]) -> List[List[int]]:
-        nums.sort()
-        result = []
-        length = len(nums)
-
-        for i in range(length - 2):
-            if i > 0 and nums[i] == nums[i - 1]:
-                continue
-
-            left = i + 1
-            right = length - 1
-
-            while left < right:
-                total = nums[i] + nums[left] + nums[right]
-
-                if total < 0:
-                    left += 1
-                elif total > 0:
-                    right -= 1
-                else:
-                    result.append([nums[i], nums[left], nums[right]])
-
-                    while left < right and nums[left] == nums[left + 1]:
-                        left += 1
-                    while left < right and nums[right] == nums[right - 1]:
-                        right -= 1
-
-                    left += 1
-                    right -= 1
-
-        return result
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `threeSum` that takes an array `nums` as input and returns a list of unique triplets whose sum is equal to zero. The example usage demonstrates how to create an instance of the `Solution` class and call the `threeSum` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0017_letter_combinations_of_a_phone_number/readme.md b/src/main/python/g0001_0100/s0017_letter_combinations_of_a_phone_number/readme.md
index 209244c..321410a 100644
--- a/src/main/python/g0001_0100/s0017_letter_combinations_of_a_phone_number/readme.md
+++ b/src/main/python/g0001_0100/s0017_letter_combinations_of_a_phone_number/readme.md
@@ -116,30 +116,4 @@ digits3 = "2"
 print(solution.letterCombinations(digits3))  # Output: ["a","b","c"]
 ```
 
-This code defines a `Solution` class with a method `letterCombinations` that takes a string of digits as input and returns a list of all possible letter combinations. The example usage demonstrates how to create an instance of the `Solution` class and call the `letterCombinations` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def letterCombinations(self, digits: str) -> List[str]:
-        if not digits:
-            return []
-
-        letters = ["", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
-        ans = []
-        self.findCombinations(0, digits, letters, [], ans)
-        return ans
-
-    def findCombinations(self, start, digits, letters, curr, ans):
-        if len(curr) == len(digits):
-            ans.append("".join(curr))
-            return
-
-        for i in range(start, len(digits)):
-            n = int(digits[i])
-            for ch in letters[n]:
-                curr.append(ch)
-                self.findCombinations(i + 1, digits, letters, curr, ans)
-                curr.pop()
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `letterCombinations` that takes a string of digits as input and returns a list of all possible letter combinations. The example usage demonstrates how to create an instance of the `Solution` class and call the `letterCombinations` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0019_remove_nth_node_from_end_of_list/readme.md b/src/main/python/g0001_0100/s0019_remove_nth_node_from_end_of_list/readme.md
index 0e1516c..3459552 100644
--- a/src/main/python/g0001_0100/s0019_remove_nth_node_from_end_of_list/readme.md
+++ b/src/main/python/g0001_0100/s0019_remove_nth_node_from_end_of_list/readme.md
@@ -109,30 +109,4 @@ n3 = 1
 result3 = solution.removeNthFromEnd(head3, n3)  # Output: ListNode(1)
 ```
 
-This code defines a `ListNode` class representing a node in the linked list and a `Solution` class with a method `removeNthFromEnd` that takes the head of the linked list and an integer `n` as input, removes the `nth` node from the end of the list, and returns the head of the modified list. The example usage demonstrates how to create instances of the `ListNode` class and call the `removeNthFromEnd` method with different inputs.
-
-## Solution
-
-```python
-# Definition for singly-linked list.
-# class ListNode:
-#     def __init__(self, val=0, next=None):
-#         self.val = val
-#         self.next = next
-class Solution:
-    def removeNthFromEnd(self, head: Optional[ListNode], n: int) -> Optional[ListNode]:
-        self.n = n
-        dummy = ListNode(0, head)
-        self._removeNth(dummy)
-        return dummy.next
-
-    def _removeNth(self, node):
-        if not node.next:
-            return
-        
-        self._removeNth(node.next)
-        self.n -= 1
-        
-        if self.n == 0:
-            node.next = node.next.next
-```
\ No newline at end of file
+This code defines a `ListNode` class representing a node in the linked list and a `Solution` class with a method `removeNthFromEnd` that takes the head of the linked list and an integer `n` as input, removes the `nth` node from the end of the list, and returns the head of the modified list. The example usage demonstrates how to create instances of the `ListNode` class and call the `removeNthFromEnd` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0020_valid_parentheses/readme.md b/src/main/python/g0001_0100/s0020_valid_parentheses/readme.md
index ff23110..7884098 100644
--- a/src/main/python/g0001_0100/s0020_valid_parentheses/readme.md
+++ b/src/main/python/g0001_0100/s0020_valid_parentheses/readme.md
@@ -117,24 +117,4 @@ input5 = "{[]}"
 result5 = solution.isValid(input5)  # Output: True
 ```
 
-This code defines a `Solution` class with a method `isValid` that takes a string `s` as input and returns `True` if the parentheses in the input string are valid and `False` otherwise. The example usage demonstrates how to create an instance of the `Solution` class and call the `isValid` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def isValid(self, s):
-        stack = []
-        for char in s:
-            if char in "({[":
-                stack.append(char)
-            elif char == ')' and stack and stack[-1] == '(':
-                stack.pop()
-            elif char == '}' and stack and stack[-1] == '{':
-                stack.pop()
-            elif char == ']' and stack and stack[-1] == '[':
-                stack.pop()
-            else:
-                return False
-        return not stack
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `isValid` that takes a string `s` as input and returns `True` if the parentheses in the input string are valid and `False` otherwise. The example usage demonstrates how to create an instance of the `Solution` class and call the `isValid` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0021_merge_two_sorted_lists/readme.md b/src/main/python/g0001_0100/s0021_merge_two_sorted_lists/readme.md
index f499459..932f4a3 100644
--- a/src/main/python/g0001_0100/s0021_merge_two_sorted_lists/readme.md
+++ b/src/main/python/g0001_0100/s0021_merge_two_sorted_lists/readme.md
@@ -106,36 +106,4 @@ l2_3 = ListNode(0)
 result3 = solution.mergeTwoLists(l1_3, l2_3)  # Output: ListNode(0)
 ```
 
-This code defines a `ListNode` class representing a node in the linked list and a `Solution` class with a method `mergeTwoLists` that takes two sorted linked lists (`l1` and `l2`) as input and returns a new sorted linked list obtained by merging the nodes of `l1` and `l2`. The example usage demonstrates how to create instances of the `ListNode` class and call the `mergeTwoLists` method with different inputs.
-
-## Solution
-
-```python
-# Definition for singly-linked list.
-# class ListNode:
-#     def __init__(self, val=0, next=None):
-#         self.val = val
-#         self.next = next
-class Solution:
-    def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
-        dummy = ListNode(-1)
-        current = dummy
-        
-        while list1 is not None or list2 is not None:
-            if list1 is not None and list2 is not None:
-                if list1.val <= list2.val:
-                    current.next = ListNode(list1.val)
-                    list1 = list1.next
-                else:
-                    current.next = ListNode(list2.val)
-                    list2 = list2.next
-            elif list1 is not None:
-                current.next = ListNode(list1.val)
-                list1 = list1.next
-            else:
-                current.next = ListNode(list2.val)
-                list2 = list2.next
-            current = current.next
-            
-        return dummy.next
-```
\ No newline at end of file
+This code defines a `ListNode` class representing a node in the linked list and a `Solution` class with a method `mergeTwoLists` that takes two sorted linked lists (`l1` and `l2`) as input and returns a new sorted linked list obtained by merging the nodes of `l1` and `l2`. The example usage demonstrates how to create instances of the `ListNode` class and call the `mergeTwoLists` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0022_generate_parentheses/readme.md b/src/main/python/g0001_0100/s0022_generate_parentheses/readme.md
index a90f354..88ebf66 100644
--- a/src/main/python/g0001_0100/s0022_generate_parentheses/readme.md
+++ b/src/main/python/g0001_0100/s0022_generate_parentheses/readme.md
@@ -84,27 +84,4 @@ n2 = 1
 result2 = solution.generateParenthesis(n2)  # Output: ["()"]
 ```
 
-This code defines a `Solution` class with a method `generateParenthesis` that takes an integer `n` as input and returns a list containing all combinations of well-formed parentheses for `n` pairs. The example usage demonstrates how to create an instance of the `Solution` class and call the `generateParenthesis` method with different inputs.
-
-## Solution
-
-```python
-class Solution:
-    def generateParenthesis(self, n: int) -> List[str]:
-        ans = []
-        self._generate([], ans, n, n)
-        return ans
-
-    def _generate(self, current, result, open, close):
-        if open == 0 and close == 0:
-            result.append("".join(current))
-            return
-        if open > 0:
-            current.append('(')
-            self._generate(current, result, open - 1, close)
-            current.pop()
-        if close > 0 and open < close:
-            current.append(')')
-            self._generate(current, result, open, close - 1)
-            current.pop()
-```
\ No newline at end of file
+This code defines a `Solution` class with a method `generateParenthesis` that takes an integer `n` as input and returns a list containing all combinations of well-formed parentheses for `n` pairs. The example usage demonstrates how to create an instance of the `Solution` class and call the `generateParenthesis` method with different inputs.
\ No newline at end of file
diff --git a/src/main/python/g0001_0100/s0056_merge_intervals/readme.md b/src/main/python/g0001_0100/s0056_merge_intervals/readme.md
index c90738f..642bda3 100644
--- a/src/main/python/g0001_0100/s0056_merge_intervals/readme.md
+++ b/src/main/python/g0001_0100/s0056_merge_intervals/readme.md
@@ -64,19 +64,4 @@ intervals2 = \[\[1, 4], [4, 5]]
 sol = Solution()
 print(sol.merge(intervals1))  # Output: [[1, 6], [8, 10], [15, 18]]
 print(sol.merge(intervals2))  # Output: [[1, 5]]
-```
-
-## Solution
-
-```python
-class Solution:
-    def merge(self, intervals: List[List[int]]) -> List[List[int]]:
-        intervals.sort(key=lambda x: x[0])
-        merged = []
-        for interval in intervals:
-            if not merged or merged[-1][1] < interval[0]:
-                merged.append(interval)
-            else:
-                merged[-1][1] = max(merged[-1][1], interval[1])
-        return merged
 ```
\ No newline at end of file
