Skip to content

Commit ba82f64

Browse files
committed
update
1 parent 90af2af commit ba82f64

File tree

172 files changed

+248
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+248
-248
lines changed

Python/3sum-smaller.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n^2)
22
# Space: O(1)
33

4-
class Solution:
4+
class Solution(object):
55
# @param {integer[]} nums
66
# @param {integer} target
77
# @return {integer}

Python/add-and-search-word-data-structure-design.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Time: O(min(n, h)), per operation
22
# Space: O(min(n, h))
33

4-
class TrieNode:
4+
class TrieNode(object):
55
# Initialize your data structure here.
66
def __init__(self):
77
self.is_string = False
88
self.leaves = {}
99

1010

11-
class WordDictionary:
11+
class WordDictionary(object):
1212
def __init__(self):
1313
self.root = TrieNode()
1414

Python/add-binary.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Space: O(1)
33

44

5-
class Solution:
5+
class Solution(object):
66
# @param a, a string
77
# @param b, a string
88
# @return a string

Python/add-two-numbers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(1)
33

4-
class ListNode:
4+
class ListNode(object):
55
def __init__(self, x):
66
self.val = x
77
self.next = None

Python/basic-calculator-ii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Space: O(n)
33

44

5-
class Solution:
5+
class Solution(object):
66
# @param {string} s
77
# @return {integer}
88
def calculate(self, s):

Python/basic-calculator-iv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import itertools
1111

1212

13-
class Poly(collections.Counter):
13+
class Poly(collections.Counter)(object):
1414
def __init__(self, expr=None):
1515
if expr is None:
1616
return

Python/basic-calculator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Space: O(n)
33

44

5-
class Solution:
5+
class Solution(object):
66
# @param {string} s
77
# @return {integer}
88
def calculate(self, s):

Python/best-time-to-buy-and-sell-stock-ii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Space: O(1)
33

44

5-
class Solution:
5+
class Solution(object):
66
# @param prices, a list of integer
77
# @return an integer
88
def maxProfit(self, prices):

Python/candy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import operator
55
from functools import reduce
66

7-
class Solution:
7+
class Solution(object):
88
# @param ratings, a list of integer
99
# @return an integer
1010
def candy(self, ratings):

Python/climbing-stairs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(1)
33

4-
class Solution:
4+
class Solution(object):
55
"""
66
:type n: int
77
:rtype: int

Python/clone-graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Time: O(n)
22
# Space: O(n)
33

4-
class UndirectedGraphNode:
4+
class UndirectedGraphNode(object):
55
def __init__(self, x):
66
self.label = x
77
self.neighbors = []
88

9-
class Solution:
9+
class Solution(object):
1010
# @param node, a undirected graph node
1111
# @return a undirected graph node
1212
def cloneGraph(self, node):

Python/combination-sum-ii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(k * C(n, k))
22
# Space: O(k)
33

4-
class Solution:
4+
class Solution(object):
55
# @param candidates, a list of integers
66
# @param target, integer
77
# @return a list of lists of integers

Python/combination-sum-iii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(k * C(n, k))
22
# Space: O(k)
33

4-
class Solution:
4+
class Solution(object):
55
# @param {integer} k
66
# @param {integer} n
77
# @return {integer[][]}

Python/combination-sum.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(k * n^k)
22
# Space: O(k)
33

4-
class Solution:
4+
class Solution(object):
55
# @param candidates, a list of integers
66
# @param target, integer
77
# @return a list of lists of integers

Python/construct-binary-tree-from-inorder-and-postorder-traversal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Time: O(n)
22
# Space: O(n)
33

4-
class TreeNode:
4+
class TreeNode(object):
55
def __init__(self, x):
66
self.val = x
77
self.left = None
88
self.right = None
99

10-
class Solution:
10+
class Solution(object):
1111
# @param inorder, a list of integers
1212
# @param postorder, a list of integers
1313
# @return a tree node

Python/construct-binary-tree-from-preorder-and-inorder-traversal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Time: O(n)
22
# Space: O(n)
33

4-
class TreeNode:
4+
class TreeNode(object):
55
def __init__(self, x):
66
self.val = x
77
self.left = None
88
self.right = None
99

10-
class Solution:
10+
class Solution(object):
1111
# @param preorder, a list of integers
1212
# @param inorder, a list of integers
1313
# @return a tree node

Python/container-with-most-water.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(1)
33

4-
class Solution:
4+
class Solution(object):
55
# @return an integer
66
def maxArea(self, height):
77
max_area, i, j = 0, 0, len(height) - 1

Python/contains-duplicate-ii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(n)
33

4-
class Solution:
4+
class Solution(object):
55
# @param {integer[]} nums
66
# @param {integer} k
77
# @return {boolean}

Python/contains-duplicate-iii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import collections
55

66

7-
class Solution:
7+
class Solution(object):
88
# @param {integer[]} nums
99
# @param {integer} k
1010
# @param {integer} t

Python/contains-duplicate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(n)
33

4-
class Solution:
4+
class Solution(object):
55
# @param {integer[]} nums
66
# @return {boolean}
77
def containsDuplicate(self, nums):

Python/convert-sorted-array-to-binary-search-tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(logn)
33

4-
class TreeNode:
4+
class TreeNode(object):
55
def __init__(self, x):
66
self.val = x
77
self.left = None

Python/convert-sorted-list-to-binary-search-tree.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# Time: O(n)
22
# Space: O(logn)
33

4-
class TreeNode:
4+
class TreeNode(object):
55
def __init__(self, x):
66
self.val = x
77
self.left = None
88
self.right = None
99
#
1010
# Definition for singly-linked list.
11-
class ListNode:
11+
class ListNode(object):
1212
def __init__(self, x):
1313
self.val = x
1414
self.next = None
1515

16-
class Solution:
16+
class Solution(object):
1717
head = None
1818
# @param head, a list node
1919
# @return a tree node

Python/copy-list-with-random-pointer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Time: O(n)
22
# Space: O(1)
33

4-
class RandomListNode:
4+
class RandomListNode(object):
55
def __init__(self, x):
66
self.label = x
77
self.next = None
88
self.random = None
99

10-
class Solution:
10+
class Solution(object):
1111
# @param head, a RandomListNode
1212
# @return a RandomListNode
1313
def copyRandomList(self, head):
@@ -37,7 +37,7 @@ def copyRandomList(self, head):
3737

3838
# Time: O(n)
3939
# Space: O(n)
40-
class Solution2:
40+
class Solution2(object):
4141
# @param head, a RandomListNode
4242
# @return a RandomListNode
4343
def copyRandomList(self, head):

Python/count-and-say.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n * 2^n)
22
# Space: O(2^n)
33

4-
class Solution:
4+
class Solution(object):
55
# @return a string
66
def countAndSay(self, n):
77
seq = "1"

Python/count-complete-tree-nodes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(h * logn) = O((logn)^2)
22
# Space: O(1)
33

4-
class Solution:
4+
class Solution(object):
55
# @param {TreeNode} root
66
# @return {integer}
77
def countNodes(self, root):

Python/count-primes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(n)
33

4-
class Solution:
4+
class Solution(object):
55
# @param {integer} n
66
# @return {integer}
77
def countPrimes(self, n):

Python/count-univalue-subtrees.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(h)
33

4-
class Solution:
4+
class Solution(object):
55
# @param {TreeNode} root
66
# @return {integer}
77
def countUnivalSubtrees(self, root):

Python/delete-node-in-a-linked-list.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(1)
22
# Space: O(1)
33

4-
class Solution:
4+
class Solution(object):
55
# @param {ListNode} node
66
# @return {void} Do not return anything, modify node in-place instead.
77
def deleteNode(self, node):

Python/design-linked-list.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(n)
33

4-
class Node:
4+
class Node(object):
55
def __init__(self, value):
66
self.val = value
77
self.next = self.prev = None

Python/different-ways-to-add-parentheses.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import re
99

1010

11-
class Solution:
11+
class Solution(object):
1212
# @param {string} input
1313
# @return {integer[]}
1414
def diffWaysToCompute(self, input):
@@ -30,7 +30,7 @@ def diffWaysToComputeRecu(left, right):
3030

3131
return diffWaysToComputeRecu(0, len(nums) - 1)
3232

33-
class Solution2:
33+
class Solution2(object):
3434
# @param {string} input
3535
# @return {integer[]}
3636
def diffWaysToCompute(self, input):

Python/distinct-subsequences.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n^2)
22
# Space: O(n)
33

4-
class Solution:
4+
class Solution(object):
55
# @return an integer
66
def numDistinct(self, S, T):
77
ways = [0 for _ in xrange(len(T) + 1)]

Python/divide-two-integers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(logn) = O(1)
22
# Space: O(1)
33

4-
class Solution:
4+
class Solution(object):
55
def divide(self, dividend, divisor):
66
"""
77
:type dividend: int

Python/dungeon-game.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(m * n)
22
# Space: O(m + n)
33

4-
class Solution:
4+
class Solution(object):
55
# @param dungeon, a list of lists of integers
66
# @return a integer
77
def calculateMinimumHP(self, dungeon):
@@ -18,7 +18,7 @@ def calculateMinimumHP(self, dungeon):
1818

1919
# Time: O(m * n logk), where k is the possible maximum sum of loses
2020
# Space: O(m + n)
21-
class Solution2:
21+
class Solution2(object):
2222
# @param dungeon, a list of lists of integers
2323
# @return a integer
2424
def calculateMinimumHP(self, dungeon):

Python/edit-distance.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n * m)
22
# Space: O(n + m)
33

4-
class Solution:
4+
class Solution(object):
55
# @return an integer
66
def minDistance(self, word1, word2):
77
if len(word1) < len(word2):
@@ -25,7 +25,7 @@ def minDistance(self, word1, word2):
2525

2626
# Time: O(n * m)
2727
# Space: O(n * m)
28-
class Solution2:
28+
class Solution2(object):
2929
# @return an integer
3030
def minDistance(self, word1, word2):
3131
distance = [[i] for i in xrange(len(word1) + 1)]

Python/encode-and-decode-strings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Time: O(n)
22
# Space: O(1)
33

4-
class Codec:
4+
class Codec(object):
55

66
def encode(self, strs):
77
"""Encodes a list of strings to a single string.

0 commit comments

Comments
 (0)