Leetcode-Solution
文章平均质量分 74
主Python语言,后期会增加C++的部分
ep_mashiro
日拱一卒,功不唐捐
展开
-
剑指Offer题解(Python版)
二叉树的镜像链表中环的入口结点删除链表中重复的结点从尾到头打印链表斐波那契数列跳台阶变态跳台阶矩形覆盖把字符串转换成整数平衡二叉树和为S的连续正数序列左旋转字符串数字在排序数组中出现的次数数组中只出现一次的数字翻转单词顺序列二叉树的深度和为S的两个数字顺时针打印矩阵二叉树的下一个结点对称的二叉树把二叉树打印成多行按之字形顺序打印二叉树序列化二叉树二叉...原创 2018-02-14 17:56:18 · 27222 阅读 · 12 评论 -
Leetcode TwoPointer知识点总结
344. Reverse String:字符串转置,Easy 定义头尾指针,调换对应的字符 class Solution(object): def reverseString(self, s): """ :type s: str :rtype: str """ s = list(s...原创 2018-04-18 15:10:08 · 483 阅读 · 0 评论 -
Leetcode Binary Search 知识点总结
744. Find Smallest Letter Greater Than Target:返回目标字母target插入到有序字母列表letters后下一个字母,如果target无下一个字母,则返回letters[0],Easy 二分插入 index = bisect.bisect(letters, target) return letters[index % len(l...原创 2018-04-22 11:07:06 · 455 阅读 · 0 评论 -
Leetcode Hash Table知识点总结
454. 4Sum II:求满足A[i]+B[j]+C[k]+D[l] = 0的 (i,j,k,l)个数,Medium http://bookshadow.com/weblog/2016/11/13/leetcode-4sum-ii/ 利用字典cnt,将A,B中各元素(笛卡尔积)的和进行分类计数。 将C,D中各元素(笛卡尔积)和的相反数在cnt中的值进行累加,即为答案。...原创 2018-04-22 11:19:30 · 360 阅读 · 0 评论 -
Leetcode Array 知识点总结
832. Flipping an Image:将数据先水平翻转,再01交换,返回数据。Easyclass Solution(object): def flipAndInvertImage(self, A): """ :type A: List[List[int]] :rtype: List[List[int]] "...原创 2018-05-16 10:42:26 · 414 阅读 · 0 评论 -
八大排序算法
参考 理了一下八大排序(to do list好多年终于填掉了) 人是真的要锤大锤打才能成长起来哇~ 舍友过生日,先撤了~# - * - coding:utf8 - * - -'''@Author : Tinkle G@Creation Time: 2018/03/16'''class Solution(object): ########################...原创 2018-03-16 20:46:15 · 296 阅读 · 0 评论 -
算法专题训练(1)股票问题
121. Best Time to Buy and Sell Stock:股票一次买入卖出,求最大利润class Solution(object): def maxProfit(self, prices): if prices == []: return 0 minNum,ret = prices[0],0 for p in pr...原创 2018-03-10 11:04:15 · 826 阅读 · 0 评论 -
算法专题训练(2)小偷问题
198. House Robber:小偷不能偷相邻的房子,求最大收益class Solution(object): def rob(self, nums): size = len(nums) if size == 0: return 0 if size <=2: return max(nums) Values =...原创 2018-03-13 21:00:26 · 3238 阅读 · 0 评论 -
算法专题训练(3)回文字符串
516. Longest Palindromic Subsequence:求字符串中最大回文子串(不一定连续)的最大长度 将s翻转成s1 求s和s1的最长公共子序列长度 可以先判断下s是否是回文 另外一个思路 dp[i][j] = dp[i + 1][j - 1] + 2 if s[i] == s[j] dp[i][j] = max(dp...原创 2018-03-17 21:23:07 · 283 阅读 · 0 评论 -
Leetcode DFS知识点总结
Depth-first-search104. Maximum Depth of Binary Tree:求树的最大深度, Easyclass Solution(object): def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ ...原创 2018-04-07 12:44:15 · 2116 阅读 · 1 评论 -
Leetcode 链表知识点总结
来看下Leetcode中Tag为[ Linked-List ](https://leetcode.com/tag/linked-list/ )的题目[ 141. Linked List Cycle ](https://leetcode.com/problems/linked- list-cycle / description / ):判断一个链表是否存在环,Easy [ 142.链接列表循环II ...原创 2018-02-17 15:11:19 · 1134 阅读 · 0 评论 -
Leetcode 位运算知识点总结
一个颇有好感的爱豆今天入伍了,人品和才华都没的说,但是因为这样或那样的原因,最终不得已提前进了部队,挺心疼他的。明年年底见吧。 昨天刷B站,看到国内一个练习生选秀节目中舞蹈导师批评国内练习生各种借口各种不努力,不禁感慨国内娱乐圈来钱太容易了。韩国爱豆生存压力大,每年出道的团很多,但是最后活下来的就那么几个。所以为了成功,他们需要不断努力不停练习,最终的表现和国内高下立判。 环境是很大的一个方面...原创 2018-03-05 11:05:12 · 554 阅读 · 0 评论 -
Leetcode 递归知识点总结
自古套路留人心,发现自己对递归这块掌握的真的是“感人肺腑“(最近的语文水平断崖式下跌哎)来看下Leetcode中Tag为Recursion的题目 [Leetcode 687] Longest Univalue Path:给定二叉树,求节点值全部相等的最长路径。路径不一定要通过树根。Easy# Definition for a binary tree node.# clas...原创 2018-03-06 11:26:18 · 885 阅读 · 0 评论 -
Leetcode 栈知识点总结
来看下Leetcode中Tag为Stack的题目[Leetcode 739] Daily Temperatures:求下一个温暖天气距离当前日期的时间差。Mediumclass Solution(object): def dailyTemperatures(self, temperatures): """ :type temperatures...原创 2018-03-07 09:06:39 · 905 阅读 · 0 评论 -
Leetcode 动态规划知识点总结
来看下Leetcode中Tag为Dynamic Programming的题目股票买卖系列小偷光顾房子系列斐波那列序列及其变种70. Climbing Stairs:爬山问题,Easy dp[i] = dp[i-1]+dp[i-2]746. Min Cost Climbing Stairs:爬山问题,需要支付cost[i]费用,Easyclass Sol...原创 2018-03-13 20:42:53 · 432 阅读 · 0 评论 -
Leetcode Math知识点总结
728. Self Dividing Numbers:返回[left,right+1]区间内所有自分数的列表(自分数即该数%各位上的数=0,含0的数不是自分数), Easyclass Solution(object): def selfDividingNumbers(self, left, right): """ :type left: int...原创 2018-03-22 16:05:56 · 509 阅读 · 0 评论