zhangjunjia / awesome-zhangjunjia Goto Github PK
View Code? Open in Web Editor NEW以此repository记录学习成长的milestone
以此repository记录学习成长的milestone
# https://leetcode-cn.com/problems/combinations/
# 77. 组合
# clarify 不能有重复组合,穷尽所有可能组合
# possible solution 回溯?!
#
from collections import deque
class Solution(object):
def combine(self, n, k):
"""
:type n: int
:type k: int
:rtype: List[List[int]]
"""
result, queue = [], []
def helper(start, end, num):
# terminator
if num == 0:
result.append(queue[:])
return
for i in range(start, end+1):
# reduce compute
if end - i + 1 >= num:
queue.append(i)
# dfs
helper(i+1, end, num-1)
# reverse
queue.pop()
helper(1, n, k)
return result
# https://leetcode-cn.com/problems/permutations/
# 46.全排列
# test case => [], [1], [1,2], [1,2,3]
class Solution(object):
def permute(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
if len(nums) <= 1:
return [nums]
def helper(queue, lst, res):
if not lst:
res.append(queue[:])
return
for i, num in enumerate(lst):
queue.append(num)
helper(queue, lst[:i] + lst[i+1:], res)
queue.pop() # reverse
res = []
helper([], nums, res)
return res
# https://leetcode-cn.com/problems/permutations-ii/
# 47. 全排列2
class Solution(object):
def permuteUnique(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
if len(nums) <= 1:
return [nums]
def helper(queue, lst, res):
if not lst:
res.append(queue[:])
return
for i, num in enumerate(lst):
if not i or num != lst[i-1]: # 起点一样剪枝掉
queue.append(num)
helper(queue, lst[:i]+lst[i+1:], res)
queue.pop()
res = []
nums.sort()
helper([], nums, res)
return res
The Amazon Builder's Library Review
这个系列inspired by Paper 阅读记录,目标是今年阅读40篇左右的优秀paper,而且每一篇阅读完后都要做输出总结。
论文阅读的方法参考wangzzu paper read和如何阅读科研论文。
6W原则:
读3遍原则:
资源列表:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.