From 9c1994e1da0d9c52acccaf741bf78ac4b289734f Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 26 Oct 2025 04:16:32 -0600 Subject: [PATCH] adding algo --- .../top_150_questions_round_21/remove_element.py | 11 +++++++++++ .../test_remove_element_round_21.py | 13 +++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/my_project/interviews/top_150_questions_round_21/remove_element.py create mode 100644 tests/test_150_questions_round_21/test_remove_element_round_21.py diff --git a/src/my_project/interviews/top_150_questions_round_21/remove_element.py b/src/my_project/interviews/top_150_questions_round_21/remove_element.py new file mode 100644 index 00000000..8521e400 --- /dev/null +++ b/src/my_project/interviews/top_150_questions_round_21/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_21/test_remove_element_round_21.py b/tests/test_150_questions_round_21/test_remove_element_round_21.py new file mode 100644 index 00000000..56b7f5d1 --- /dev/null +++ b/tests/test_150_questions_round_21/test_remove_element_round_21.py @@ -0,0 +1,13 @@ +import unittest +from src.my_project.interviews.top_150_questions_round_21\ +.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