Skip to content

Commit 954f671

Browse files
authored
Merge pull request #1436 from ivan1016017/october26
adding algo
2 parents 2d18189 + 9c1994e commit 954f671

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import List, Union, Collection, Mapping, Optional
2+
from abc import ABC, abstractmethod
3+
4+
class Solution:
5+
6+
def removeElement(self, nums: List[int], val: int) -> int:
7+
8+
while val in nums:
9+
nums.remove(val)
10+
11+
return len(nums)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import unittest
2+
from src.my_project.interviews.top_150_questions_round_21\
3+
.remove_element import Solution
4+
5+
class RemoveElementTestCase(unittest.TestCase):
6+
7+
def test_remove_element(self):
8+
solution = Solution()
9+
output = solution.removeElement(nums=[3,2,2,3], val=3)
10+
target = 2
11+
self.assertEqual(output, target)
12+
13+

0 commit comments

Comments
 (0)