本文整理汇总了Python中solution.Solution.lengthOfLongestSubstring方法的典型用法代码示例。如果您正苦于以下问题:Python Solution.lengthOfLongestSubstring方法的具体用法?Python Solution.lengthOfLongestSubstring怎么用?Python Solution.lengthOfLongestSubstring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solution.Solution
的用法示例。
在下文中一共展示了Solution.lengthOfLongestSubstring方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestCase
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import lengthOfLongestSubstring [as 别名]
class TestCase(unittest.TestCase):
def setUp(self):
self.solution = Solution()
def test_solution1(self):
self.assertEqual(self.solution.lengthOfLongestSubstring('abcabcbb'), 3)
def test_solution2(self):
self.assertEqual(self.solution.lengthOfLongestSubstring('bbbbb'), 1)
def test_solution3(self):
self.assertEqual(self.solution.lengthOfLongestSubstring('abcabcdefabcdefg'), 7)
示例2: test
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import lengthOfLongestSubstring [as 别名]
def test():
sol = Solution()
assert sol.lengthOfLongestSubstring("") == 0
assert sol.lengthOfLongestSubstring("abcabcbb") == 3
assert sol.lengthOfLongestSubstring("bbbbb") == 1
assert sol.lengthOfLongestSubstring("abcdeeabcd") == 5
示例3: Solution
# 需要导入模块: from solution import Solution [as 别名]
# 或者: from solution.Solution import lengthOfLongestSubstring [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from solution import Solution
sol = Solution()
input = 'abcabcdcdeotgr'
result = sol.lengthOfLongestSubstring(input)
print(result)