This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/multiply-strings/description/ | |
class Solution(object): | |
def multiply(self, num1, num2): | |
""" | |
:type num1: str | |
:type num2: str | |
:rtype: str | |
""" | |
temp_values = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/coin-change/description/ | |
class Solution(object): | |
def coinChange(self, coins, amount): | |
""" | |
:type coins: List[int] | |
:type amount: int | |
:rtype: int | |
""" | |
if amount == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/description/ | |
# Definition for a binary tree node. | |
# class TreeNode(object): | |
# def __init__(self, x): | |
# self.val = x | |
# self.left = None | |
# self.right = None | |
class Solution(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/reverse-string-ii/description/ | |
class Solution(object): | |
def reverseStr(self, s, k): | |
""" | |
:type s: str | |
:type k: int | |
:rtype: str | |
""" | |
half_k = k//2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/diameter-of-binary-tree/description/ | |
# Definition for a binary tree node. | |
# class TreeNode(object): | |
# def __init__(self, x): | |
# self.val = x | |
# self.left = None | |
# self.right = None | |
class Solution(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/base-7/description/ | |
class Solution(object): | |
BASE_EXP = [1, 7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607] | |
def convertToBase7(self, num): | |
""" | |
:type num: int | |
:rtype: str | |
""" | |
def add_x_to_digits(x, digit_list): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/maximum-product-of-three-numbers/description/ | |
class Solution(object): | |
def maximumProduct(self, nums): | |
""" | |
:type nums: List[int] | |
:rtype: int | |
""" | |
length = len(nums) | |
if length == 3: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/integer-break/description/ | |
class Solution(object): | |
def integerBreak(self, n): | |
""" | |
:type n: int | |
:rtype: int | |
""" | |
if n == 1 or n == 2: | |
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/4sum-ii/description/ | |
class Solution(object): | |
def fourSumCount(self, A, B, C, D): | |
""" | |
:type A: List[int] | |
:type B: List[int] | |
:type C: List[int] | |
:type D: List[int] | |
:rtype: int | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://leetcode.com/problems/total-hamming-distance/description/ | |
class Solution(object): | |
def totalHammingDistance(self, nums): | |
""" | |
:type nums: List[int] | |
:rtype: int | |
""" | |
i = 0 |
NewerOlder