![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
小鹅鹅
兴趣使然
展开
-
LeetCode 322. Coin Change Python 动态规划/BFS解法
题目描述You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of原创 2018-01-17 00:30:24 · 3991 阅读 · 0 评论 -
LeetCode 22. Generate Parentheses 生成括号 Python 回溯解法
题目描述Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. 给定n对括号,写一个函数来生成成对的括号的所有组合。 For example, given n = 3, a solution set is: [ “((()))原创 2018-01-18 23:48:43 · 4049 阅读 · 0 评论 -
LeetCode 5. Longest Palindromic Substring 最长回文子串 Python 四种解法(Manacher 动态规划)
Longest Palindromic Substring 最长回文子串 学习笔记1. Brute method第一种方法:直接循环求解,o(n2)o(n^2)class Solution: def longestPalindrome(self, s): """ :type s: str :rtype: str原创 2018-01-06 11:41:46 · 17352 阅读 · 3 评论 -
Leetcode 206. Reverse Linked List 链表翻转 Python 两种解法
问题描述Reverse a singly linked list. 翻转一个链表#1第一种方法:迭代class ListNode(object): def __init__(self, x): self.val = x self.next = Noneclass Solution(object): def reverseList...原创 2018-03-15 18:04:47 · 1664 阅读 · 0 评论 -
Leetcode 78. Subsets Python DFS 深度优先搜索解法
问题描述Given a set of distinct integers, nums, return all possible subsets (the power set). 给定一个数据集合,求该集合的所有子集。 Note: The solution set must not contain duplicate subsets.For example, If nums = [1,...原创 2018-03-15 18:37:00 · 2092 阅读 · 0 评论 -
逆序数对(inversion)个数统计 python解法与时间复杂度推导
问题描述Letx1,x2,...,xnx1,x2,...,xn x_1, x_2, . . . , x_n be a list of n distinct input integers. We call the pair (i, j) an inversion if i < j and xi>xjxi>xjx_i > x_j . Give a divide-and-conqu...原创 2018-03-04 14:18:33 · 4189 阅读 · 4 评论 -
LeetCode 139. Word Break 动态规划DP Python解法
题目Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may ...原创 2018-03-24 00:21:27 · 3162 阅读 · 0 评论 -
扇形染色问题 Python解法
问题描述将一个圆形等分成N个小扇形,将这些扇形标记为1,2,3,…,N。现在使用M种颜色对每个扇形进行涂色,每个扇形涂一种颜色,且相邻的扇形颜色不同。求:有多少种涂色方法。 备注:不考虑数值越界。N>=1,M>=3;思路设a(n)a(n)a(n)为符合要求的第nnn个扇形的涂色方法。 对扇形1有m种涂色方法,扇形2有m-1m-1m-1种涂色方法,扇形3也...原创 2018-03-14 17:00:00 · 1773 阅读 · 0 评论