![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
三笔竹林
程序媛的自我修养
展开
-
LeetCode刷题Day1 Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use thesame原创 2017-07-20 14:04:18 · 273 阅读 · 0 评论 -
136.SingleNum+ 217.Contains DuplicateI&II+448. Find All Numbers Disappeared inArray+442.AllDuplicate
总结了几道leetcode中常见的同类型题到底是谁重复了到底是谁丢了大合集!Come on!Leetcode 136 SingleNumber(无序,所有数都重复了两遍,只有一个数重复了一遍。很有特点的题,用异或方法解题)问题:Given an array of integers, every element appears twice except for原创 2017-10-10 16:40:03 · 227 阅读 · 0 评论 -
Leetcode 动态规划最长公共子序列+ 198HouseRobbingI+II +746Min Cost Climbing Stairs
动态规划解解题思路总结:一个很复杂的问题可以分解成形式类似,模式更小的问题。先尝试解决这个小问题,再扩大到大问题。要从小问题中看出动态规划状态转移式(表达式)。最长公共子串LCSubstringstr1='abcdscde'str2='jaserewcderew'def getNumofCommonSubStr(str1,str2): lenstr1=len(str1)...原创 2018-02-04 14:48:49 · 339 阅读 · 0 评论 -
Search a 2D matrix II(剑指offer2.3原题)
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in each col...原创 2018-02-07 12:21:07 · 228 阅读 · 0 评论 -
766. Toeplitz Matrix
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz. Example 1:Input: m原创 2018-01-29 11:57:49 · 288 阅读 · 1 评论 -
Leetcode Hash Table专题 389. Find the Difference+771. Jewels and Stones+554. Brick Wall
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was added ...原创 2018-01-29 12:37:02 · 219 阅读 · 0 评论 -
463 IsLand Perimeter
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely翻译 2018-01-29 21:40:41 · 141 阅读 · 0 评论 -
Leetcode链表专题
Leetcode链表专题Python与C链表操作对比Leetcode21-剑指OFFER面试题25合并两个有序的链表思路分析代码Leetcode206Reverse Linked List剑指OFFER面试题24 反转链表思路分析代码Python与C++链表操作对比C++判断一个节点是不是空节点的写法://比如:void Doing(Lis...原创 2018-02-26 16:57:48 · 369 阅读 · 0 评论 -
Leetcode树专题
树的常识三种遍历方法对应的数据结构Leetcode257.Binary Tree Paths思路:很典型的深度优先搜索配合栈,宽度优先搜索配合队列。学一个遍历二叉树的方法Leetcode111. Minimum Depth of Binary Tree(求二叉树的最短深度)较差的思路:从上题思路套用而来,先求得所有路径的节点数(就是长度),再求最小值较好的思路:宽度优先搜...原创 2018-02-27 15:35:02 · 848 阅读 · 0 评论 -
Leetcode 刷题 Binary Search Easy难度经验总结
[TOC]刷了4道Binary Search Easy难度的题二叉搜索思想好想,难在边界的控制上,于是乎我就在思考能不能背下一个定式,遇到二分搜索的题目就套这个定式。我做的第一道二叉搜索的题目就是一个很好的定式:#744. Find Smallest Letter Greater Than TargetGiven a list of sorted characters letters conta...原创 2017-12-24 11:21:45 · 309 阅读 · 0 评论 -
LeetcodeArray283 MoveZero +LeetcodeArrary26 Remove Duplicates from Sorted Array
这是我在微软面试过程中,真的遇到的面试题,但我没想到,答案竟然如此简单:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1...原创 2017-11-21 17:11:55 · 166 阅读 · 0 评论 -
LINUX SHELL命令学习
Linux常用命令/ 常见面试题ls和echoShell创建第一个shell脚本执行shell脚本作为可执行程序执行作为解释器参数执行脚本变量定义变量使用变量只读变量删除变量变量类型查看文件内容catvimLeetcode例题实操1Leetcode例题实操2 截取文件的某一行sed(属于文档编辑命令)如何查看某一行的长度如何截取某些行...原创 2018-04-03 16:05:33 · 296 阅读 · 0 评论 -
神奇的数字 202. Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares原创 2018-02-01 18:44:22 · 330 阅读 · 0 评论 -
118.Pascal's Triangle
118. Pascal's TriangleGiven numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]原创 2018-01-24 15:48:02 · 168 阅读 · 0 评论 -
Leetcode刷题day2
二分法解决插入数到有序数组并返回位置index问题原创 2017-07-24 16:52:53 · 221 阅读 · 0 评论 -
Leetcode刷题Day3 Palindrome Number
java判断回文数字原创 2017-08-10 15:36:21 · 178 阅读 · 0 评论 -
Leetcode 刷题 Day4 136.SingleNumber
Leetcode136 singleNumber原创 2017-08-15 15:30:38 · 205 阅读 · 0 评论 -
Leetcode Day5 20. Valid Parentheses Python 栈的实现
Leetcode 20 括号匹配 链表 栈原创 2017-10-09 18:10:01 · 248 阅读 · 0 评论 -
Leetcode Day6 2. Add Two Numbers I & II
Leetcode AddTwoNumbersI and II自从昨天AC了第一道链表题以后,今天对链表用的得心应手多了今天AC了112MS,打败了90.17%的python submission,我觉得还可以就没看别的做法原题:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in原创 2017-10-10 13:53:55 · 191 阅读 · 0 评论 -
Leetcode 645 FindErrorNum
The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of原创 2017-10-30 19:37:45 · 382 阅读 · 0 评论 -
Leetcode665 (Array) Non-decreasing Array +Leetcode674 Longest Continuous Increasing Subsequence
Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element.We define an array is non-decreasing if array[i] holds for every i (1原创 2017-11-22 19:15:56 · 227 阅读 · 0 评论 -
Leetcode141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?这道题的经典之处在于它的思想, "Easier to ask for forgiveness than permission."妈呀人生哲理~翻译 2017-11-23 17:41:17 · 165 阅读 · 0 评论 -
67.Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".我的原创解法:62ms,打败了14.46%的python答案我的思路:和十进制加法的套路一样class Solution(object): def原创 2018-01-02 11:31:35 · 234 阅读 · 0 评论 -
Leetcode图专题
要明白的基础知识node1=UndirectedGraphNode(1)node2=UndirectedGraphNode(2)nodeMap={}nodeMap[node1]="hello"nodeMap[node2]="world"#这样是合法的,打印nodeMap看看nodeMapOut[8]: {<__main__.UndirectedGraphNode at 0x...原创 2018-09-22 21:20:54 · 1776 阅读 · 0 评论