From 3a7505531beb3233d1bea1feecbcbeae8a4ce597 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 21 Sep 2025 04:23:36 -0600 Subject: [PATCH] adding algo --- .../top_150_questions_round_20/remove_element.py | 11 +++++++++++ .../test_remove_element_round_20.py | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/my_project/interviews/top_150_questions_round_20/remove_element.py create mode 100644 tests/test_150_questions_round_20/test_remove_element_round_20.py diff --git a/src/my_project/interviews/top_150_questions_round_20/remove_element.py b/src/my_project/interviews/top_150_questions_round_20/remove_element.py new file mode 100644 index 00000000..00f47696 --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_20/remove_element.py @@ -0,0 +1,11 @@ +from typing import List, Union, Collection, Mapping, Optional +from abc import ABC, abstractmethod + +class Solution: + + def removeElement(self, nums: List[int], val: int) -> int: + + while val in nums: + nums.remove(val) + + return len(nums) \ No newline at end of file diff --git a/tests/test_150_questions_round_20/test_remove_element_round_20.py b/tests/test_150_questions_round_20/test_remove_element_round_20.py new file mode 100644 index 00000000..333c1d7e --- /dev/null +++ b/tests/test_150_questions_round_20/test_remove_element_round_20.py @@ -0,0 +1,11 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_20\ +.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) \ No newline at end of file