• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python solution.Solution类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中solution.Solution的典型用法代码示例。如果您正苦于以下问题:Python Solution类的具体用法?Python Solution怎么用?Python Solution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Solution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_0

def test_0():
    sol = Solution()
    assert sol.uniquePathsWithObstacles([]) == 0
    assert sol.uniquePathsWithObstacles([[0, 0, 0]]) == 1
    assert sol.uniquePathsWithObstacles([[0, 1, 0]]) == 0
    assert sol.uniquePathsWithObstacles([[0], [0], [0]]) == 1
    assert sol.uniquePathsWithObstacles([[0], [1], [0]]) == 0
开发者ID:misaka-10032,项目名称:leetcode,代码行数:7,代码来源:test.py


示例2: TestCase

class TestCase(unittest.TestCase):

    def setUp(self):
        self.solution = Solution()

    def testSolution01(self):
        a = (1, 3, 5, 7, 9, 11)
        b = (2, 4, 6, 8, 10)
        self.assertEqual(self.solution.findMedianSortedArrays(a, b), 6)

    def testSolution02(self):
        a = (1, 3, 4, 5, 7, 9)
        b = (2, 6, 8, 10)
        self.assertEqual(self.solution.findMedianSortedArrays(a, b), 5.5)

    def testSolution03(self):
        a = (1, 2, 3, 4, 5, 9)
        b = (6, 7, 8, 10, 11)
        self.assertEqual(self.solution.findMedianSortedArrays(a, b), 6)

    def testSolution04(self):
        a = (1, 2, 3, 4, 5, 6)
        b = (7, 8, 9, 10, 11)
        self.assertEqual(self.solution.findMedianSortedArrays(a, b), 6)

    def testSolution05(self):
        a = (1, 4, 8, 9, 10, 11)
        b = (2, 3, 5, 6, 7)
        self.assertEqual(self.solution.findMedianSortedArrays(a, b), 6)
开发者ID:romain-li,项目名称:leetcode,代码行数:29,代码来源:test.py


示例3: test_1

def test_1():
    sol = Solution()
    nums = [1, 2, 3]
    ans = [[1, 2, 3], [1, 3, 2],
           [2, 1, 3], [2, 3, 1],
           [3, 1, 2], [3, 2, 1]]
    assert sorted(ans) == sorted(sol.permute(nums))
开发者ID:misaka-10032,项目名称:leetcode,代码行数:7,代码来源:test.py


示例4: test1

 def test1(self):
     s = Solution()
     beginWord = "hit"
     endWord = "cog"
     wordDict = set(["hot","dot","dog","lot","log"])
     res = s.findLadders(beginWord, endWord, wordDict)
     print res
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:7,代码来源:test.py


示例5: test2

    def test2(self):
        head = Node()
        head.buff = [1, 2, 3]
        head.count = 3

        n1 = Node()
        n1.buff = [4]
        n1.count = 1

        n2 = Node()
        n2.buff = [5, 6]
        n2.count = 2

        head.next = n1
        n1.next = n2

        sol = Solution()
        res = sol.get_idx_at(head, 0)
        exp = 1
        self.assertEqual(res, exp)

        res = sol.get_idx_at(head, 1)
        exp = 2
        self.assertEqual(res, exp)

        res = sol.get_idx_at(head, 4)
        exp = 5
        self.assertEqual(res, exp)

        res = sol.get_idx_at(head, 5)
        exp = 6
        self.assertEqual(res, exp)
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:32,代码来源:test.py


示例6: test1

 def test1(self):
     array = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
     k = 5
     exp = 5
     sol = Solution()
     res = sol.kth_smallset(array, k)
     self.assertEqual(res, exp)
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:7,代码来源:test.py


示例7: test_2

def test_2():
    sol = Solution()
    matrix = [['1', '1', '1', '0', '0'],
              ['1', '1', '1', '1', '1'],
              ['1', '1', '1', '1', '1'],
              ['1', '0', '0', '1', '0']]
    assert sol.maximalSquare(matrix) == 9
开发者ID:misaka-10032,项目名称:leetcode,代码行数:7,代码来源:test.py


示例8: test4

 def test4(self):
     s = Solution()
     input_str = 'aaaaaaaaaaaaab'
     p = 'a*a*a*a*a*a*a*a*a*a*c'
     res = s.isMatch(input_str, p)
     print res
     self.assertFalse(res)
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:7,代码来源:test.py


示例9: test3

 def test3(self):
     s = Solution()
     input_str = 'aab'
     p = 'c*a*b'
     res = s.isMatch(input_str, p)
     print res
     self.assertTrue(res)
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:7,代码来源:test.py


示例10: test3

    def test3(self):
        node1 = ListNode(1)
        node2 = ListNode(2)
        node3 = ListNode(3)
        node4 = ListNode(4)
        node5 = ListNode(5)
        node6 = ListNode(6)
        node7 = ListNode(7)
        node8 = ListNode(8)
        node9 = ListNode(9)
        node10 = ListNode(10)
        node11 = ListNode(11)
        node12 = ListNode(12)
        node13 = ListNode(13)
        node13 = ListNode(13)

        node1.next = node2
        node2.next = node3
        node3.next = node4
        node4.next = node5
        node5.next = node6
        node6.next = node1

        node7.next = node8
        node8.next = node9
        node9.next = node10
        node10.next = node11
        node11.next = node12
        node12.next = node13
        node12.next = node7

        s = Solution()
        res = s.is_interset(node1, node7)
        print res
        self.assertFalse(res)
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:35,代码来源:test.py


示例11: test_parameter_types

    def test_parameter_types(self):
        s = Solution('test_data/example/info.yaml')
        params = s.get_parameter_types(None)

        self.assertEqual(len(params), 5)

        self.assertEqual(params[0]['name'], 'floating-network-id')
        self.assertEqual(params[0]['type'], 'comma_delimited_list')
        self.assertIn(params[0]['default'],
                      params[0]['constraints'][0]['allowed_values'])
        self.assertIn('_mapping', params[0])
        self.assertEqual(params[0]['_mapping'], {'first_network': '11',
                                                 'second_network': '22',
                                                 'third_network': '33'})
        self.assertEqual(s.map_parameter(params, 'floating-network-id',
                                         'second_network'), '22')

        self.assertEqual(params[1]['name'], 'flavor')
        self.assertEqual(params[1]['type'], 'comma_delimited_list')
        self.assertIn(params[1]['default'], 'm1.small')

        self.assertEqual(params[2]['name'], 'image')
        self.assertEqual(params[2]['type'], 'comma_delimited_list')
        self.assertIn(params[2]['default'],
                      params[2]['constraints'][0]['allowed_values'])

        self.assertEqual(params[3]['name'], 'image-count')
        self.assertEqual(params[3]['type'], 'number')

        self.assertEqual(params[4]['name'], 'keyname')
        self.assertEqual(params[4]['type'], 'comma_delimited_list')
        self.assertIn(params[4]['default'],
                      params[4]['constraints'][0]['allowed_values'])
开发者ID:jacobwagner,项目名称:horizon-extensions,代码行数:33,代码来源:tests.py


示例12: test001

 def test001(self):
     s = Solution()
     numbers = [5,2,5,1,4,3,6,4,3,2,6]
     n = s.singleNumber(numbers)
     print "input:\t", numbers
     print "expect:\t", 1
     print "output:\t", n
开发者ID:54lihaoxin,项目名称:leetcode_python,代码行数:7,代码来源:test_suite.py


示例13: test5

 def test5(self):
     s = Solution()
     beginWord = "a"
     endWord = "c"
     wordDict = set(["a", "b", "c"])
     res = s.findLadders(beginWord, endWord, wordDict)
     print res
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:7,代码来源:test.py


示例14: test2

 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)
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:7,代码来源:test.py


示例15: test1

    def test1(self):
        node1 = Node(1)
        node2 = Node(2)
        node3 = Node(3)
        node4 = Node(4)
        node5 = Node(5)
        node6 = Node(6)
        node7 = Node(7)
        node8 = Node(8)
        node9 = Node(9)
        node10 = Node(10)
        node11 = Node(11)
        node1.left = node2
        node1.right = node3
        node2.left = node4
        node2.right = node5
        node3.left = node6
        node3.right = node7
        node6.left = node8
        node6.right = node9
        node7.left = node10
        node7.right = node11

        s = Solution()
        res = s.compress(node1)
        print res
        root = s.decompress(res)
        res2 = s.compress(root)
        print res2
        self.assertEqual(res, res2)
开发者ID:johnnywsd,项目名称:leetcode_python,代码行数:30,代码来源:test.py



注:本文中的solution.Solution类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python predefined_solutions.simple_static_linear函数代码示例发布时间:2022-05-27
下一篇:
Python solution.what_is_my_sign函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap