diff --git a/src/my_project/interviews/interview_amazon/round_1/algo_1.py b/src/my_project/interviews/interview_amazon/round_1/algo_1.py new file mode 100644 index 00000000..dc258b73 --- /dev/null +++ b/src/my_project/interviews/interview_amazon/round_1/algo_1.py @@ -0,0 +1,24 @@ +from typing import List + +class Solution: + + def algo_1(self, names: List[str]): + + dic_solution = dict() + + for n in names: + if n in dic_solution: + dic_solution[n] += 1 + else: + dic_solution[n] = 1 + + names.sort(key=lambda x: dic_solution[x], reverse=True) + + + return names[0], dic_solution[names[0]] + + + +solution = Solution() + +print(solution.algo_1(names=['paola','mariana','mariana'])) \ No newline at end of file diff --git a/src/my_project/interviews/interview_amazon/round_1/algo_2.py b/src/my_project/interviews/interview_amazon/round_1/algo_2.py new file mode 100644 index 00000000..eb25dbe9 --- /dev/null +++ b/src/my_project/interviews/interview_amazon/round_1/algo_2.py @@ -0,0 +1,17 @@ +from typing import List + +class Solution: + + def algo_1(self, names: List[str]): + + + names.sort(key=lambda x: len(x), reverse=True) + + + return names[0] + + + +solution = Solution() + +print(solution.algo_1(names=['paola','mariana','stephanos'])) \ No newline at end of file diff --git a/src/my_project/interviews/interview_amazon/round_1/algo_3.py b/src/my_project/interviews/interview_amazon/round_1/algo_3.py new file mode 100644 index 00000000..e69de29b diff --git a/src/my_project/interviews/top_150_questions_round_17/remove_element.py b/src/my_project/interviews/top_150_questions_round_17/remove_element.py new file mode 100644 index 00000000..2d27a419 --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_17/remove_element.py @@ -0,0 +1,13 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC + +class Solution: + + def removeElement(self, nums: List[int], val: int) -> int: + + while val in nums: + + nums.remove(val) + + return len(nums) + diff --git a/tests/test_150_questions_round_17/test_remove_element_round_17.py b/tests/test_150_questions_round_17/test_remove_element_round_17.py new file mode 100644 index 00000000..b43032e6 --- /dev/null +++ b/tests/test_150_questions_round_17/test_remove_element_round_17.py @@ -0,0 +1,11 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_17\ +.remove_element import Solution + +class RemoveElementTestCase(unittest.TestCase): + + def test_remove_element(self): + solution = Solution() + output = solution.removeElement(nums=[3,2,2,3], val=3) + target = 2 + self.assertEqual(output, target)