From b31db3eabc6f87b56cfb735ff8acc38169019b24 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 2 Dec 2025 04:28:29 -0600 Subject: [PATCH 1/2] adding algo --- .../common_algos/two_sum_round_22.py | 16 ++++++ .../common_algos/valid_palindrome_round_22.py | 23 +++++++++ ...d_array.py => ex_01_merge_sorted_array.py} | 0 ...ove_element.py => ex_02_remove_element.py} | 0 ...ates_i.py => ex_03_remove_duplicates_i.py} | 0 ...es_ii.py => ex_04_remove_duplicates_ii.py} | 0 ...y_element.py => ex_05_majority_element.py} | 0 ...{rotate_array.py => ex_06_rotate_array.py} | 0 ...py => ex_07_best_time_to_sell_stocks_i.py} | 0 ...y => ex_08_best_time_to_sell_stocks_ii.py} | 0 .../ex_09_jump_game_i.py | 49 +++++++++++++++++++ .../ex_10_jump_game_ii.py | 34 +++++++++++++ ...=> test_01_merge_sorted_array_round_22.py} | 2 +- ....py => test_02_remove_element_round_22.py} | 2 +- ...> test_03_remove_duplicates_i_round_22.py} | 2 +- ... test_04_remove_duplicates_ii_round_22.py} | 2 +- ...y => test_05_majority_element_round_22.py} | 2 +- ...22.py => test_06_rotate_array_round_22.py} | 2 +- ...07_best_time_to_sell_stocks_i_round_22.py} | 2 +- ...8_best_time_to_sell_stocks_ii_round_22.py} | 2 +- .../test_09_jump_game_i_round_22.py | 15 ++++++ .../test_10_jump_game_ii_round_22.py | 17 +++++++ 22 files changed, 162 insertions(+), 8 deletions(-) create mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_22.py create mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_22.py rename src/my_project/interviews/top_150_questions_round_22/{merge_sorted_array.py => ex_01_merge_sorted_array.py} (100%) rename src/my_project/interviews/top_150_questions_round_22/{remove_element.py => ex_02_remove_element.py} (100%) rename src/my_project/interviews/top_150_questions_round_22/{remove_duplicates_i.py => ex_03_remove_duplicates_i.py} (100%) rename src/my_project/interviews/top_150_questions_round_22/{remove_duplicates_ii.py => ex_04_remove_duplicates_ii.py} (100%) rename src/my_project/interviews/top_150_questions_round_22/{majority_element.py => ex_05_majority_element.py} (100%) rename src/my_project/interviews/top_150_questions_round_22/{rotate_array.py => ex_06_rotate_array.py} (100%) rename src/my_project/interviews/top_150_questions_round_22/{best_time_to_sell_stocks_i.py => ex_07_best_time_to_sell_stocks_i.py} (100%) rename src/my_project/interviews/top_150_questions_round_22/{best_time_to_sell_stocks_ii.py => ex_08_best_time_to_sell_stocks_ii.py} (100%) create mode 100644 src/my_project/interviews/top_150_questions_round_22/ex_09_jump_game_i.py create mode 100644 src/my_project/interviews/top_150_questions_round_22/ex_10_jump_game_ii.py rename tests/test_150_questions_round_22/{test_merge_sorted_array_round_22.py => test_01_merge_sorted_array_round_22.py} (90%) rename tests/test_150_questions_round_22/{test_remove_element_round_22.py => test_02_remove_element_round_22.py} (89%) rename tests/test_150_questions_round_22/{test_remove_duplicates_i_round_22.py => test_03_remove_duplicates_i_round_22.py} (87%) rename tests/test_150_questions_round_22/{test_remove_duplicates_ii_round_22.py => test_04_remove_duplicates_ii_round_22.py} (87%) rename tests/test_150_questions_round_22/{test_majority_element_round_22.py => test_05_majority_element_round_22.py} (92%) rename tests/test_150_questions_round_22/{test_rotate_array_round_22.py => test_06_rotate_array_round_22.py} (90%) rename tests/test_150_questions_round_22/{test_best_time_to_sell_stocks_i_round_22.py => test_07_best_time_to_sell_stocks_i_round_22.py} (86%) rename tests/test_150_questions_round_22/{test_best_time_to_sell_stocks_ii_round_22.py => test_08_best_time_to_sell_stocks_ii_round_22.py} (86%) create mode 100644 tests/test_150_questions_round_22/test_09_jump_game_i_round_22.py create mode 100644 tests/test_150_questions_round_22/test_10_jump_game_ii_round_22.py diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_22.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_22.py new file mode 100644 index 00000000..6c0c6330 --- /dev/null +++ b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_22.py @@ -0,0 +1,16 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC, abstractmethod + +class Solution: + def twoSum(self, nums: List[int], target: int) -> List[int]: + + answer = dict() + + for k, v in enumerate(nums): + + if v in answer: + return [answer[v], k] + else: + answer[target - v] = k + + return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_22.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_22.py new file mode 100644 index 00000000..dfc57cd7 --- /dev/null +++ b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_22.py @@ -0,0 +1,23 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC, abstractmethod +import re + +class Solution: + def isPalindrome(self, s: str) -> bool: + + # To lowercase + s = s.lower() + + # Remove non-alphanumeric characters + s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) + + # Determine if s is palindrome or not + + len_s = len(s) + + for i in range(len_s//2): + + if s[i] != s[len_s - 1 - i]: + return False + + return True \ No newline at end of file diff --git a/src/my_project/interviews/top_150_questions_round_22/merge_sorted_array.py b/src/my_project/interviews/top_150_questions_round_22/ex_01_merge_sorted_array.py similarity index 100% rename from src/my_project/interviews/top_150_questions_round_22/merge_sorted_array.py rename to src/my_project/interviews/top_150_questions_round_22/ex_01_merge_sorted_array.py diff --git a/src/my_project/interviews/top_150_questions_round_22/remove_element.py b/src/my_project/interviews/top_150_questions_round_22/ex_02_remove_element.py similarity index 100% rename from src/my_project/interviews/top_150_questions_round_22/remove_element.py rename to src/my_project/interviews/top_150_questions_round_22/ex_02_remove_element.py diff --git a/src/my_project/interviews/top_150_questions_round_22/remove_duplicates_i.py b/src/my_project/interviews/top_150_questions_round_22/ex_03_remove_duplicates_i.py similarity index 100% rename from src/my_project/interviews/top_150_questions_round_22/remove_duplicates_i.py rename to src/my_project/interviews/top_150_questions_round_22/ex_03_remove_duplicates_i.py diff --git a/src/my_project/interviews/top_150_questions_round_22/remove_duplicates_ii.py b/src/my_project/interviews/top_150_questions_round_22/ex_04_remove_duplicates_ii.py similarity index 100% rename from src/my_project/interviews/top_150_questions_round_22/remove_duplicates_ii.py rename to src/my_project/interviews/top_150_questions_round_22/ex_04_remove_duplicates_ii.py diff --git a/src/my_project/interviews/top_150_questions_round_22/majority_element.py b/src/my_project/interviews/top_150_questions_round_22/ex_05_majority_element.py similarity index 100% rename from src/my_project/interviews/top_150_questions_round_22/majority_element.py rename to src/my_project/interviews/top_150_questions_round_22/ex_05_majority_element.py diff --git a/src/my_project/interviews/top_150_questions_round_22/rotate_array.py b/src/my_project/interviews/top_150_questions_round_22/ex_06_rotate_array.py similarity index 100% rename from src/my_project/interviews/top_150_questions_round_22/rotate_array.py rename to src/my_project/interviews/top_150_questions_round_22/ex_06_rotate_array.py diff --git a/src/my_project/interviews/top_150_questions_round_22/best_time_to_sell_stocks_i.py b/src/my_project/interviews/top_150_questions_round_22/ex_07_best_time_to_sell_stocks_i.py similarity index 100% rename from src/my_project/interviews/top_150_questions_round_22/best_time_to_sell_stocks_i.py rename to src/my_project/interviews/top_150_questions_round_22/ex_07_best_time_to_sell_stocks_i.py diff --git a/src/my_project/interviews/top_150_questions_round_22/best_time_to_sell_stocks_ii.py b/src/my_project/interviews/top_150_questions_round_22/ex_08_best_time_to_sell_stocks_ii.py similarity index 100% rename from src/my_project/interviews/top_150_questions_round_22/best_time_to_sell_stocks_ii.py rename to src/my_project/interviews/top_150_questions_round_22/ex_08_best_time_to_sell_stocks_ii.py diff --git a/src/my_project/interviews/top_150_questions_round_22/ex_09_jump_game_i.py b/src/my_project/interviews/top_150_questions_round_22/ex_09_jump_game_i.py new file mode 100644 index 00000000..738b5b66 --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_22/ex_09_jump_game_i.py @@ -0,0 +1,49 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC, abstractmethod + +class Solution: + + def canJump(self, nums: List[int]) -> bool: + """ + Determine if we can jump from index 0 to the last index. + + Strategy: Greedy backward traversal + - Work backwards from the end + - Track the leftmost position that can reach the goal + - If we can reach index 0, return True + + Time: O(n), Space: O(n) - can be optimized to O(1) + """ + + n = len(nums) + + # Base case: already at the end + if n == 1: + return True + + # dp[i] = 1 means position i can reach the end + dp = [0] * n + + # Start from the last index (our goal) + prev_best = n - 1 + step = n - 1 + + # Iterate backwards from second-to-last to first index + for i in range(n - 2, -1, -1): + # Maximum jump length from current position + step = nums[i] + + # Check if current position can reach any "good" position + # (i + step) is the farthest we can jump from position i + if (i + step) >= prev_best: + # Mark this position as reachable to the end + dp[i] = 1 + + # Update the leftmost position that can reach the end + prev_best = i + + # Check if we can reach the end from the start (index 0) + if dp[0]: + return True + + return False \ No newline at end of file diff --git a/src/my_project/interviews/top_150_questions_round_22/ex_10_jump_game_ii.py b/src/my_project/interviews/top_150_questions_round_22/ex_10_jump_game_ii.py new file mode 100644 index 00000000..2321b45f --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_22/ex_10_jump_game_ii.py @@ -0,0 +1,34 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC, abstractmethod + +class Solution: + def jump(self, nums: List[int]) -> int: + """ + Greedy approach: At each position, jump to the farthest reachable index + + Example: [2,3,1,1,4] + - From index 0 (value=2): can reach indices 1,2 + - Greedy choice: Jump to index 1 (value=3) because it reaches farthest + - From index 1: can reach indices 2,3,4 (end) + - Answer: 2 jumps + """ + + if len(nums) <= 1: + return 0 + + jumps = 0 + current_end = 0 # End of current jump range + farthest = 0 # The farthest position we can reach + + for i in range(len(nums) - 1): + # Update farthest position reachable + farthest = max(farthest, i + nums[i]) + + # If we've reached the end of current jump range + if i == current_end: + jumps += 1 + current_end = farthest # Make the greedy choice + + if current_end > len(nums) - 1: + break + return jumps \ No newline at end of file diff --git a/tests/test_150_questions_round_22/test_merge_sorted_array_round_22.py b/tests/test_150_questions_round_22/test_01_merge_sorted_array_round_22.py similarity index 90% rename from tests/test_150_questions_round_22/test_merge_sorted_array_round_22.py rename to tests/test_150_questions_round_22/test_01_merge_sorted_array_round_22.py index 35ea220c..baecb244 100644 --- a/tests/test_150_questions_round_22/test_merge_sorted_array_round_22.py +++ b/tests/test_150_questions_round_22/test_01_merge_sorted_array_round_22.py @@ -1,6 +1,6 @@ import unittest from src.my_project.interviews.top_150_questions_round_22\ -.merge_sorted_array import Solution +.ex_01_merge_sorted_array import Solution class MergeSortedArrayTestCase(unittest.TestCase): diff --git a/tests/test_150_questions_round_22/test_remove_element_round_22.py b/tests/test_150_questions_round_22/test_02_remove_element_round_22.py similarity index 89% rename from tests/test_150_questions_round_22/test_remove_element_round_22.py rename to tests/test_150_questions_round_22/test_02_remove_element_round_22.py index 5e5bd4b0..b798003d 100644 --- a/tests/test_150_questions_round_22/test_remove_element_round_22.py +++ b/tests/test_150_questions_round_22/test_02_remove_element_round_22.py @@ -1,6 +1,6 @@ import unittest from src.my_project.interviews.top_150_questions_round_22\ -.remove_element import Solution +.ex_02_remove_element import Solution class RemoveElementTestCase(unittest.TestCase): diff --git a/tests/test_150_questions_round_22/test_remove_duplicates_i_round_22.py b/tests/test_150_questions_round_22/test_03_remove_duplicates_i_round_22.py similarity index 87% rename from tests/test_150_questions_round_22/test_remove_duplicates_i_round_22.py rename to tests/test_150_questions_round_22/test_03_remove_duplicates_i_round_22.py index 4229aa61..9285f99c 100644 --- a/tests/test_150_questions_round_22/test_remove_duplicates_i_round_22.py +++ b/tests/test_150_questions_round_22/test_03_remove_duplicates_i_round_22.py @@ -1,6 +1,6 @@ import unittest from src.my_project.interviews.top_150_questions_round_22\ -.remove_duplicates_i import Solution +.ex_03_remove_duplicates_i import Solution class RemoveDuplicatesTestCase(unittest.TestCase): diff --git a/tests/test_150_questions_round_22/test_remove_duplicates_ii_round_22.py b/tests/test_150_questions_round_22/test_04_remove_duplicates_ii_round_22.py similarity index 87% rename from tests/test_150_questions_round_22/test_remove_duplicates_ii_round_22.py rename to tests/test_150_questions_round_22/test_04_remove_duplicates_ii_round_22.py index 9308c29f..642fbcf0 100644 --- a/tests/test_150_questions_round_22/test_remove_duplicates_ii_round_22.py +++ b/tests/test_150_questions_round_22/test_04_remove_duplicates_ii_round_22.py @@ -1,6 +1,6 @@ import unittest from src.my_project.interviews.top_150_questions_round_22\ -.remove_duplicates_ii import Solution +.ex_04_remove_duplicates_ii import Solution class RemoveDuplicatesTestCaseII(unittest.TestCase): def test_remove_duplicates(self): diff --git a/tests/test_150_questions_round_22/test_majority_element_round_22.py b/tests/test_150_questions_round_22/test_05_majority_element_round_22.py similarity index 92% rename from tests/test_150_questions_round_22/test_majority_element_round_22.py rename to tests/test_150_questions_round_22/test_05_majority_element_round_22.py index d64c9011..e8801b04 100644 --- a/tests/test_150_questions_round_22/test_majority_element_round_22.py +++ b/tests/test_150_questions_round_22/test_05_majority_element_round_22.py @@ -1,6 +1,6 @@ import unittest from src.my_project.interviews.top_150_questions_round_22\ -.majority_element import Solution +.ex_05_majority_element import Solution class MajorityElementTestCase(unittest.TestCase): diff --git a/tests/test_150_questions_round_22/test_rotate_array_round_22.py b/tests/test_150_questions_round_22/test_06_rotate_array_round_22.py similarity index 90% rename from tests/test_150_questions_round_22/test_rotate_array_round_22.py rename to tests/test_150_questions_round_22/test_06_rotate_array_round_22.py index 275983d0..eed2dd03 100644 --- a/tests/test_150_questions_round_22/test_rotate_array_round_22.py +++ b/tests/test_150_questions_round_22/test_06_rotate_array_round_22.py @@ -1,6 +1,6 @@ import unittest from src.my_project.interviews.top_150_questions_round_22\ -.rotate_array import Solution +.ex_06_rotate_array import Solution class RotateArrayTestCase(unittest.TestCase): diff --git a/tests/test_150_questions_round_22/test_best_time_to_sell_stocks_i_round_22.py b/tests/test_150_questions_round_22/test_07_best_time_to_sell_stocks_i_round_22.py similarity index 86% rename from tests/test_150_questions_round_22/test_best_time_to_sell_stocks_i_round_22.py rename to tests/test_150_questions_round_22/test_07_best_time_to_sell_stocks_i_round_22.py index 7f97e98a..c85c875e 100644 --- a/tests/test_150_questions_round_22/test_best_time_to_sell_stocks_i_round_22.py +++ b/tests/test_150_questions_round_22/test_07_best_time_to_sell_stocks_i_round_22.py @@ -1,6 +1,6 @@ import unittest from src.my_project.interviews.top_150_questions_round_22\ -.best_time_to_sell_stocks_i import Solution +.ex_07_best_time_to_sell_stocks_i import Solution class BestTimeToSellStockTestCase(unittest.TestCase): diff --git a/tests/test_150_questions_round_22/test_best_time_to_sell_stocks_ii_round_22.py b/tests/test_150_questions_round_22/test_08_best_time_to_sell_stocks_ii_round_22.py similarity index 86% rename from tests/test_150_questions_round_22/test_best_time_to_sell_stocks_ii_round_22.py rename to tests/test_150_questions_round_22/test_08_best_time_to_sell_stocks_ii_round_22.py index d1370fb1..31a99a74 100644 --- a/tests/test_150_questions_round_22/test_best_time_to_sell_stocks_ii_round_22.py +++ b/tests/test_150_questions_round_22/test_08_best_time_to_sell_stocks_ii_round_22.py @@ -1,7 +1,7 @@ import unittest import unittest from src.my_project.interviews.top_150_questions_round_22\ -.best_time_to_sell_stocks_ii import Solution +.ex_08_best_time_to_sell_stocks_ii import Solution class BestTimeToSellStockTestCase(unittest.TestCase): diff --git a/tests/test_150_questions_round_22/test_09_jump_game_i_round_22.py b/tests/test_150_questions_round_22/test_09_jump_game_i_round_22.py new file mode 100644 index 00000000..4cba45c6 --- /dev/null +++ b/tests/test_150_questions_round_22/test_09_jump_game_i_round_22.py @@ -0,0 +1,15 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_22\ +.ex_09_jump_game_i import Solution + +class JumpITestCase(unittest.TestCase): + + def test_jump_i_first_case_true(self): + solution = Solution() + output = solution.canJump(nums = [2,3,1,1,4]) + self.assertTrue(output) + + def test_jump_i_first_case_false(self): + solution = Solution() + output = solution.canJump(nums = [3,2,1,0,4]) + self.assertFalse(output) \ No newline at end of file diff --git a/tests/test_150_questions_round_22/test_10_jump_game_ii_round_22.py b/tests/test_150_questions_round_22/test_10_jump_game_ii_round_22.py new file mode 100644 index 00000000..e7b97a69 --- /dev/null +++ b/tests/test_150_questions_round_22/test_10_jump_game_ii_round_22.py @@ -0,0 +1,17 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_22\ +.ex_10_jump_game_ii import Solution + +class JumpIITestCase(unittest.TestCase): + + def test_jump_i_first_case(self): + solution = Solution() + output = solution.jump(nums = [2,3,1,1,4]) + target = 2 + self.assertEqual(output, target) + + def test_jump_i_second_case(self): + solution = Solution() + output = solution.jump(nums = [2,3,0,1,4]) + target = 2 + self.assertEqual(output, target) From af7ab04885a00f2d215ac407acc856239a819266 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 2 Dec 2025 04:29:44 -0600 Subject: [PATCH 2/2] adding algo --- .../common_algos/two_sum_round_1.py | 10 ++++---- .../common_algos/two_sum_round_10.py | 16 ------------- .../common_algos/two_sum_round_11.py | 16 ------------- .../common_algos/two_sum_round_12.py | 16 ------------- .../common_algos/two_sum_round_13.py | 16 ------------- .../common_algos/two_sum_round_14.py | 16 ------------- .../common_algos/two_sum_round_15.py | 16 ------------- .../common_algos/two_sum_round_16.py | 16 ------------- .../common_algos/two_sum_round_17.py | 16 ------------- .../common_algos/two_sum_round_18.py | 16 ------------- .../common_algos/two_sum_round_19.py | 16 ------------- .../common_algos/two_sum_round_2.py | 16 ------------- .../common_algos/two_sum_round_20.py | 16 ------------- .../common_algos/two_sum_round_21.py | 16 ------------- .../common_algos/two_sum_round_22.py | 16 ------------- .../common_algos/two_sum_round_3.py | 16 ------------- .../common_algos/two_sum_round_4.py | 16 ------------- .../common_algos/two_sum_round_5.py | 17 ------------- .../common_algos/two_sum_round_6.py | 16 ------------- .../common_algos/two_sum_round_7.py | 16 ------------- .../common_algos/two_sum_round_8.py | 16 ------------- .../common_algos/two_sum_round_9.py | 16 ------------- .../common_algos/valid_palindrome_round_1.py | 11 ++++----- .../common_algos/valid_palindrome_round_10.py | 23 ------------------ .../common_algos/valid_palindrome_round_11.py | 23 ------------------ .../common_algos/valid_palindrome_round_12.py | 22 ----------------- .../common_algos/valid_palindrome_round_13.py | 23 ------------------ .../common_algos/valid_palindrome_round_14.py | 23 ------------------ .../common_algos/valid_palindrome_round_15.py | 23 ------------------ .../common_algos/valid_palindrome_round_16.py | 23 ------------------ .../common_algos/valid_palindrome_round_17.py | 23 ------------------ .../common_algos/valid_palindrome_round_18.py | 23 ------------------ .../common_algos/valid_palindrome_round_19.py | 23 ------------------ .../common_algos/valid_palindrome_round_2.py | 24 ------------------- .../common_algos/valid_palindrome_round_20.py | 23 ------------------ .../common_algos/valid_palindrome_round_21.py | 23 ------------------ .../common_algos/valid_palindrome_round_22.py | 23 ------------------ .../common_algos/valid_palindrome_round_3.py | 23 ------------------ .../common_algos/valid_palindrome_round_4.py | 22 ----------------- .../common_algos/valid_palindrome_round_5.py | 23 ------------------ .../common_algos/valid_palindrome_round_6.py | 23 ------------------ .../common_algos/valid_palindrome_round_7.py | 23 ------------------ .../common_algos/valid_palindrome_round_8.py | 23 ------------------ .../common_algos/valid_palindrome_round_9.py | 23 ------------------ 44 files changed, 10 insertions(+), 830 deletions(-) delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_10.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_11.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_12.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_13.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_14.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_15.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_16.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_17.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_18.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_19.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_2.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_20.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_21.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_22.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_3.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_4.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_5.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_6.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_7.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_8.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_9.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_10.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_11.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_12.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_13.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_14.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_15.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_16.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_17.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_18.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_19.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_2.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_20.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_21.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_22.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_3.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_4.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_5.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_6.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_7.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_8.py delete mode 100644 src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_9.py diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_1.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_1.py index f3c376b0..6c0c6330 100644 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_1.py +++ b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_1.py @@ -4,13 +4,13 @@ class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: - dic_answer = dict() + answer = dict() for k, v in enumerate(nums): - if v in dic_answer: - return [dic_answer[v], k] - - dic_answer[target - v] = k + if v in answer: + return [answer[v], k] + else: + answer[target - v] = k return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_10.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_10.py deleted file mode 100644 index cf05b635..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_10.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k,v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_11.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_11.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_11.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_12.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_12.py deleted file mode 100644 index e03fe46f..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_12.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_13.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_13.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_13.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_14.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_14.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_14.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_15.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_15.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_15.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_16.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_16.py deleted file mode 100644 index e03fe46f..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_16.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_17.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_17.py deleted file mode 100644 index 2d8643f2..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_17.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_18.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_18.py deleted file mode 100644 index e03fe46f..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_18.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_19.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_19.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_19.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_2.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_2.py deleted file mode 100644 index b5fbc9b9..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_2.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - dic_answer = dict() - - for k, v in enumerate(nums): - - if v in dic_answer: - return [k, dic_answer[v]] - else: - dic_answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_20.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_20.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_20.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_21.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_21.py deleted file mode 100644 index e03fe46f..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_21.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_22.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_22.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_22.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_3.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_3.py deleted file mode 100644 index 5f1b2b04..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_3.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [k, answer[v]] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_4.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_4.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_4.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_5.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_5.py deleted file mode 100644 index a3a7d986..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_5.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] - diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_6.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_6.py deleted file mode 100644 index e03fe46f..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_6.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_7.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_7.py deleted file mode 100644 index e4d26440..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_7.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_8.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_8.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_8.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_9.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_9.py deleted file mode 100644 index 6c0c6330..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/two_sum_round_9.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod - -class Solution: - def twoSum(self, nums: List[int], target: int) -> List[int]: - - answer = dict() - - for k, v in enumerate(nums): - - if v in answer: - return [answer[v], k] - else: - answer[target - v] = k - - return [] \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_1.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_1.py index c885a129..dfc57cd7 100644 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_1.py +++ b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_1.py @@ -5,14 +5,13 @@ class Solution: def isPalindrome(self, s: str) -> bool: - # to lowercase + # To lowercase s = s.lower() - # Remove non-alphanumerical characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) + # Remove non-alphanumeric characters + s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) - - # Identify palindrome + # Determine if s is palindrome or not len_s = len(s) @@ -21,4 +20,4 @@ def isPalindrome(self, s: str) -> bool: if s[i] != s[len_s - 1 - i]: return False - return True \ No newline at end of file + return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_10.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_10.py deleted file mode 100644 index 1ed43720..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_10.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_11.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_11.py deleted file mode 100644 index 1ed43720..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_11.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_12.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_12.py deleted file mode 100644 index 1c0734a7..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_12.py +++ /dev/null @@ -1,22 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_13.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_13.py deleted file mode 100644 index 82f08a6e..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_13.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_14.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_14.py deleted file mode 100644 index 14ef21aa..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_14.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lower - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_15.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_15.py deleted file mode 100644 index 82f08a6e..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_15.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_16.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_16.py deleted file mode 100644 index dfc57cd7..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_16.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_17.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_17.py deleted file mode 100644 index 2ecd58b3..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_17.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_18.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_18.py deleted file mode 100644 index a911a94f..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_18.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_19.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_19.py deleted file mode 100644 index 1ed43720..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_19.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_2.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_2.py deleted file mode 100644 index 9278ab43..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_2.py +++ /dev/null @@ -1,24 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if it is palindrome or not - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True - - diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_20.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_20.py deleted file mode 100644 index dfc57cd7..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_20.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_21.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_21.py deleted file mode 100644 index 82f08a6e..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_21.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_22.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_22.py deleted file mode 100644 index dfc57cd7..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_22.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern=r'[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_3.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_3.py deleted file mode 100644 index 51abc51d..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_3.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_4.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_4.py deleted file mode 100644 index e6f69dfb..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_4.py +++ /dev/null @@ -1,22 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is a palindrome or not - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_5.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_5.py deleted file mode 100644 index 1ed43720..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_5.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_6.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_6.py deleted file mode 100644 index 1ed43720..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_6.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_7.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_7.py deleted file mode 100644 index 3a6d5cb9..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_7.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_8.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_8.py deleted file mode 100644 index 1ed43720..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_8.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file diff --git a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_9.py b/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_9.py deleted file mode 100644 index 1ed43720..00000000 --- a/src/my_project/interviews/amazon_high_frequency_23/common_algos/valid_palindrome_round_9.py +++ /dev/null @@ -1,23 +0,0 @@ -from typing import List, Union, Collection, Mapping, Optional -from abc import ABC, abstractmethod -import re - -class Solution: - def isPalindrome(self, s: str) -> bool: - - # To lowercase - s = s.lower() - - # Remove non-alphanumeric characters - s = re.sub(pattern='[^a-zA-Z0-9]', repl='', string=s) - - # Determine if s is palindrome or not - - len_s = len(s) - - for i in range(len_s//2): - - if s[i] != s[len_s - 1 - i]: - return False - - return True \ No newline at end of file