Skip to content

Instantly share code, notes, and snippets.

@farkwun
farkwun / solution541.py
Created August 20, 2017 07:26
541. Reverse String II
# 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
@farkwun
farkwun / solution108.py
Created August 20, 2017 18:06
108. Convert Sorted Array to Binary Search Tree
# 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):
@farkwun
farkwun / solution322.py
Created September 11, 2017 06:11
322. Coin Change
# 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:
@farkwun
farkwun / solution43.py
Created September 16, 2017 07:12
43. Multiply Strings
# 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 = []