diff --git a/solutions/python/__pycache__/practice105.cpython-312.pyc b/solutions/python/__pycache__/practice105.cpython-312.pyc new file mode 100644 index 0000000..1a41887 Binary files /dev/null and b/solutions/python/__pycache__/practice105.cpython-312.pyc differ diff --git a/solutions/python/__pycache__/practice106.cpython-312.pyc b/solutions/python/__pycache__/practice106.cpython-312.pyc new file mode 100644 index 0000000..033273a Binary files /dev/null and b/solutions/python/__pycache__/practice106.cpython-312.pyc differ diff --git a/solutions/python/__pycache__/practice107.cpython-312.pyc b/solutions/python/__pycache__/practice107.cpython-312.pyc new file mode 100644 index 0000000..8152172 Binary files /dev/null and b/solutions/python/__pycache__/practice107.cpython-312.pyc differ diff --git a/solutions/python/__pycache__/practice108.cpython-312.pyc b/solutions/python/__pycache__/practice108.cpython-312.pyc new file mode 100644 index 0000000..67bf326 Binary files /dev/null and b/solutions/python/__pycache__/practice108.cpython-312.pyc differ diff --git a/solutions/python/__pycache__/practice109.cpython-312.pyc b/solutions/python/__pycache__/practice109.cpython-312.pyc new file mode 100644 index 0000000..b7fb104 Binary files /dev/null and b/solutions/python/__pycache__/practice109.cpython-312.pyc differ diff --git a/solutions/python/__pycache__/practice110.cpython-312.pyc b/solutions/python/__pycache__/practice110.cpython-312.pyc new file mode 100644 index 0000000..f1f7e5d Binary files /dev/null and b/solutions/python/__pycache__/practice110.cpython-312.pyc differ diff --git a/solutions/python/__pycache__/practice111.cpython-312.pyc b/solutions/python/__pycache__/practice111.cpython-312.pyc new file mode 100644 index 0000000..8fef63f Binary files /dev/null and b/solutions/python/__pycache__/practice111.cpython-312.pyc differ diff --git a/solutions/python/__pycache__/practice112.cpython-312.pyc b/solutions/python/__pycache__/practice112.cpython-312.pyc new file mode 100644 index 0000000..68c59f9 Binary files /dev/null and b/solutions/python/__pycache__/practice112.cpython-312.pyc differ diff --git a/solutions/python/practice105.py b/solutions/python/practice105.py index 4ea6351..7bc6f71 100644 --- a/solutions/python/practice105.py +++ b/solutions/python/practice105.py @@ -1,5 +1,6 @@ # Problem: Minimum Operations to Reduce Number to One # Source: https://www.geeksforgeeks.org/dsa/reduce-a-number-to-1-by-performing-given-operations/ +# Note: Greedy loop: halve even numbers; for odd numbers subtract 1, unless (n - 1) / 2 is odd and not 1, where adding 1 reaches a shorter chain of halvings n = int(input('Enter a positive integer: ')) op = 0 diff --git a/solutions/python/practice106.py b/solutions/python/practice106.py index 9495318..835d506 100644 --- a/solutions/python/practice106.py +++ b/solutions/python/practice106.py @@ -1,5 +1,6 @@ # Problem: Backspace String Compare # Source: https://leetcode.com/problems/backspace-string-compare/ +# Note: Builds the final text of s with a list as a stack ('#' pops the last character), then compares the result against t as entered s = input('Enter string s: ') t = input('Enter string t: ') diff --git a/solutions/python/practice107.py b/solutions/python/practice107.py index 9ebf49e..40d3562 100644 --- a/solutions/python/practice107.py +++ b/solutions/python/practice107.py @@ -1,5 +1,6 @@ # Problem: Buddy Strings Challenge # Source: https://leetcode.com/problems/buddy-strings/ +# Note: Brute force: tries swapping every pair of positions in a and checks whether the swapped string equals b a = input('Enter string A: ') b = input('Enter string B: ') diff --git a/solutions/python/practice108.py b/solutions/python/practice108.py index 45ee224..1141b7f 100644 --- a/solutions/python/practice108.py +++ b/solutions/python/practice108.py @@ -1,5 +1,6 @@ # Problem: Largest Number At Least Twice of Others # Source: https://leetcode.com/problems/largest-number-at-least-twice-of-others/ +# Note: Finds the maximum, then checks that every other element is at most half of it; prints the maximum's index if all pass, otherwise -1 n = int(input('Enter the number of integers: ')) print('Enter the integers:') diff --git a/solutions/python/practice109.py b/solutions/python/practice109.py index 81e1537..c96b493 100644 --- a/solutions/python/practice109.py +++ b/solutions/python/practice109.py @@ -1,5 +1,6 @@ # Problem: Find the Missing Number # Source: https://leetcode.com/problems/missing-number/ +# Note: Sorts the array, then scans neighbouring elements for the first gap; the missing number is one more than the element before the gap n = int(input('Enter the number of elements: ')) print(f'Enter {n} elements (between 1 and {n + 1}): ') diff --git a/solutions/python/practice110.py b/solutions/python/practice110.py index 7e9fcd6..203707a 100644 --- a/solutions/python/practice110.py +++ b/solutions/python/practice110.py @@ -1,5 +1,6 @@ # Problem: Intersection of Two Arrays # Source: https://leetcode.com/problems/intersection-of-two-arrays/ +# Note: Converts both arrays to sets and prints their intersection, so each common element appears once n = int(input('Enter the size of the first array: ')) print(f"Enter {n} elements of the first array (sorted):") diff --git a/solutions/python/practice111.py b/solutions/python/practice111.py index 0dcb05a..84c0547 100644 --- a/solutions/python/practice111.py +++ b/solutions/python/practice111.py @@ -1,5 +1,6 @@ # Problem: Product of Array Except Self # Source: https://leetcode.com/problems/product-of-array-except-self/ +# Note: Brute force: for each index, multiplies every other element into the answer (no division), O(n^2) n = int(input('Enter the number of elements: ')) print(f"Enter {n} elements:") diff --git a/solutions/python/practice112.py b/solutions/python/practice112.py index 958447f..a17fcd6 100644 --- a/solutions/python/practice112.py +++ b/solutions/python/practice112.py @@ -1,5 +1,6 @@ # Problem: Count CamelCase Words # Source: https://www.hackerrank.com/challenges/camelcase/problem +# Note: Walks the string once, starting a new word at each uppercase letter, and prints how many words were found s = input('Enter the CamelCase string: ')