本文整理汇总了Python中solution.Solution.removeDuplicates方法的典型用法代码示例。如果您正苦于以下问题:Python Solution.removeDuplicates方法的具体用法?Python Solution.removeDuplicates怎么用?Python Solution.removeDuplicates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solution.Solution
的用法示例。
在下文中一共展示了Solution.removeDuplicates方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import removeDuplicates [as 别名]
def test():
sol = Solution()
a = []
assert sol.removeDuplicates(a) == 0 and a == []
a = [1]
assert sol.removeDuplicates(a) == 1 and a[:1] == [1]
a = [1, 1, 2, 2, 2, 3]
assert sol.removeDuplicates(a) == 3 and a[:3] == [1, 2, 3]
示例2: test2
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import removeDuplicates [as 别名]
def test2(self):
A = [-50,-50,-49,-48,-47,-47,-47,-46,-45,-43,-42,-41,-40,-40,-40,-40,-40,-40,-39,-38,-38,-38,-38,-37,-36,-35,-34,-34,-34,-33,-32,-31,-30,-28,-27,-26,-26,-26,-25,-25,-24,-24,-24,-22,-22,-21,-21,-21,-21,-21,-20,-19,-18,-18,-18,-17,-17,-17,-17,-17,-16,-16,-15,-14,-14,-14,-13,-13,-12,-12,-10,-10,-9,-8,-8,-7,-7,-6,-5,-4,-4,-4,-3,-1,1,2,2,3,4,5,6,6,7,8,8,9,9,10,10,10,11,11,12,12,13,13,13,14,14,14,15,16,17,17,18,20,21,22,22,22,23,23,25,26,28,29,29,29,30,31,31,32,33,34,34,34,36,36,37,37,38,38,38,39,40,40,40,41,42,42,43,43,44,44,45,45,45,46,47,47,47,47,48,49,49,49,50]
output_list = [-50,-50,-49,-48,-47,-47,-46,-45,-43,-42,-41,-40,-40,-39,-38,-38,-37,-36,-35,-34,-34,-33,-32,-31,-30,-28,-27,-26,-26,-25,-25,-24,-24,-22,-22,-21,-21,-20,-19,-18,-18,-17,-17,-16,-16,-15,-14,-14,-13,-13,-12,-12,-10,-10,-9,-8,-8,-7,-7,-6,-5,-4,-4,-3,-1,1,2,2,3,4,5,6,6,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,16,17,17,18,20,21,22,22,23,23,25,26,28,29,29,30,31,31,32,33,34,34,36,36,37,37,38,38,39,40,40,41,42,42,43,43,44,44,45,45,46,47,47,48,49,49,50]
num_output = len(output_list)
s = Solution()
rtn = s.removeDuplicates(A)
self.assertEqual(rtn, num_output)
示例3: Solution
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import removeDuplicates [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from solution import Solution
inpt = [1, 1, 2]
sol = Solution()
res = sol.removeDuplicates(inpt)
print(res)
print(inpt)
示例4: test3
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import removeDuplicates [as 别名]
def test3(self):
A = [1, 1, 1, 1, 1, 1, 5, 2, 2, 2]
output_list = [1, 1, 5, 2, 2]
s = Solution()
rtn = s.removeDuplicates(A)
self.assertEqual(rtn, 5)
示例5: test1
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import removeDuplicates [as 别名]
def test1(self):
s = Solution()
ret = s.removeDuplicates(self.input1)
self.assertEqual(ret, len(self.output1))
self.assertEqual(self.input1, self.output1)
示例6: test_3
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import removeDuplicates [as 别名]
def test_3():
sol = Solution()
a = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 5]
assert sol.removeDuplicates(a) == 9 and \
a[:9] == [1, 1, 2, 2, 3, 3, 4, 5, 5]
示例7: test_2
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import removeDuplicates [as 别名]
def test_2():
sol = Solution()
a = [1, 1, 1, 2, 2, 3]
assert sol.removeDuplicates(a) == 5 and a[:5] == [1, 1, 2, 2, 3]
示例8: test_1
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import removeDuplicates [as 别名]
def test_1():
sol = Solution()
a = []
assert sol.removeDuplicates(a) == 0 and a == []
a = [1]
assert sol.removeDuplicates(a) == 1 and a[:1] == [1]