自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(74)
  • 收藏
  • 关注

原创 LeetCode---数组题目整理Easy篇

532. K-diff Pairs in an Array665. Non-decreasing Array

2018-05-28 11:00:56 549

原创 LeetCode---数组题目整理Medium篇

15. 3Sum556. Next Greater Element III

2018-05-28 10:59:38 745

原创 LeetCode---二叉树题目整理Easy篇

101. Symmetric Tree【Easy】 https://blog.csdn.net/leel0330/article/details/80228022104. Maximum Depth of Binary Tree【Easy】 https://blog.csdn.net/leel0330/article/details/80215507108. C...

2018-05-07 16:47:56 253

原创 剑指Offer选题列表

题目来源于何海涛的《剑指Offer》。版权归其所有。题目略有删减,筛选出个人觉得比较适合面试的题目。3. 二维数组中的查找 【Medium】 https://blog.csdn.net/leel0330/article/details/797861986. 根据树的遍历重建二叉树【Medium】 https://blog.csdn.net/leel0330/art...

2018-04-21 19:18:40 300

原创 二叉树三种遍历的递归和非递归实现

1. 前序遍历1.1 递归实现def pre_order(root): if root is None: return print(root.val) pre_order(root.left) pre_order(root.right)1.2 非递归实现def pre_order(root): stack = [] ...

2018-06-28 19:15:19 249

原创 Java基础---HashMap源码分析

0. 核心字段核心常量static final float DEFAULT_LOAD_FACTOR = 0.75f;static final int TREEIFY_THRESHOLD = 8;static final int UNTREEIFY_THRESHOLD = 6;核心字段transient int size;int threshold;final float...

2018-06-18 14:49:06 274

原创 Java基础---LinkedList源码分析

0. 核心字段transient int size = 0;transient Node<E> first;transient Node<E> last;Node类的定义:private static class Node<E> { E item; Node<E> next; Node<E>...

2018-06-18 12:01:06 217

原创 Java基础---ArrayList的源码分析

1. 构造函数1.1 无参构造函数private static final Object[] DEFAULTCAPACITY_EMPTY_ELEMENTDATA = {};public ArrayList() { this.elementData = DEFAULTCAPACITY_EMPTY_ELEMENTDATA;}1.2 初始化容量大小的构造函数public Ar...

2018-06-18 10:36:57 183

原创 LeetCode---154. Find Minimum in Rotated Sorted Array II

题目给出旋转数组,找出旋转数组中最小的值。旋转数组中可能有重复元素。如:Example 1:Input: [1,3,5] Output: 1Example 2:Input: [2,2,2,0,1] Output: 0Python题解class Solution: def findMin(self, nums): """ :...

2018-05-31 15:08:55 170

原创 LeetCode---81. Search in Rotated Sorted Array II

题目给出一个旋转数组和目标值,在旋转数组中找到目标值。旋转数组中可能包含重复元素。如:Example 1:Input: nums = [2,5,6,0,0,1,2], target = 0 Output: true Example 2:Input: nums = [2,5,6,0,0,1,2], target = 3 Output: falsePython题解cl...

2018-05-31 14:11:43 166

原创 LeetCode---79. Word Search

题目给出一个m * n的二维数组,里面的元素是字母,另给出一个单词,找出是否可以利用二维数组相邻的字母来构造单词。相邻意味着4个方向:上下左右。如:Example:board = [ [‘A’,’B’,’C’,’E’], [‘S’,’F’,’C’,’S’], [‘A’,’D’,’E’,’E’] ]Given word = “ABCCED”, return tr...

2018-05-31 11:24:59 179

原创 LeetCode---153. Find Minimum in Rotated Sorted Array

题目给出一个旋转数组,找出旋转数组中最小的值。如:Example 1:Input: [3,4,5,1,2] Output: 1 Example 2:Input: [4,5,6,7,0,1,2] Output: 0Python题解class Solution(object): def findMin(self, nums): """ ...

2018-05-31 10:38:28 162

原创 LeetCode---209. Minimum Size Subarray Sum

题目给出一个数组和目标值s,找出一个连续子序列,使得和不小于目标值。找出长度最小的连续子序列。如:Example: Input: s = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: the subarray [4,3] has the minimal length under the problem constraint.Pyt...

2018-05-31 10:29:57 217

原创 LeetCode---216. Combination Sum III

题目给出n和k,从1到9中选出k个数,使得k个数的和为n。1到9每个数只能使用1次。Python题解class Solution(object): def combinationSum3(self, k, n): """ :type k: int :type n: int :rtype: List[List[i...

2018-05-31 10:04:39 183

原创 LeetCode---179. Largest Number

题目给出一个非负整数的数组,组合它们,找出能组成的最大的数。因为结果可能非常大,你需要哦返回一个字符串。如:Example 1:Input: [10,2] Output: “210” Example 2:Input: [3,30,34,5,9] Output: “9534330”Note: The result may be very large, so you need...

2018-05-30 20:05:25 209

原创 LeetCode---560. Subarray Sum Equals K

题目给出一个整数数组和目标值,你需要找到所有的连续子序列,该子序列的和为目标值。输出满足该条件的子序列的个数。Python题解class Solution: def subarraySum(self, nums, k): """ :type nums: List[int] :type k: int :rtype...

2018-05-29 15:04:46 186

原创 LeetCode---152. Maximum Product Subarray

题目给出一个整数数组,找到一个连续子序列,该子序列具有最大的乘积。Python题解class Solution(object): def maxProduct(self, nums): """ :type nums: List[int] :rtype: int """ maxnum = big ...

2018-05-29 14:44:56 148

原创 LeetCode---287. Find the Duplicate Number

题目给出一个含有n+1个元素的数组,里面的元素值在1到n的范围内,找出重复的数字,假设只存在一个重复的数字,该数字的次数可能出现多次。Python题解class Solution: def findDuplicate(self, nums): """ :type nums: List[int] :rtype: bool ...

2018-05-29 14:18:03 142

原创 LeetCode---713. Subarray Product Less Than K

题目给出一个正整数数组,找出子序列,满足子序列的乘积小于指定值。输出符合要求的子序列的个数。如:Example 1: Input: nums = [10, 5, 2, 6], k = 100 Output: 8 Explanation: The 8 subarrays that have product less than 100 are: [10], [5], [2], [6], ...

2018-05-29 13:15:15 323

原创 LeetCode---670. Maximum Swap

题目给出一个非负整数,最多交换一次两个数字,找出能发现的最大整数。如果不存在,返回原数。如:Example 1: Input: 2736 Output: 7236 Explanation: Swap the number 2 and the number 7.Example 2: Input: 9973 Output: 9973 Explanation: No swap....

2018-05-29 12:55:44 211

原创 LeetCode---718. Maximum Length of Repeated Subarray

题目给出两个整数数组A和B,找出A和B的最长子数组,输出最长子数组的长度。Python题解class Solution(object): def findLength(self, A, B): """ :type A: List[int] :type B: List[int] :rtype: int ...

2018-05-29 11:57:45 195

原创 LeetCode---90. Subsets II

题目给出一个数组,里面可能包含重复元素,返回所有的子数组。注意:不能包含重复的子数组。Python题解class Solution(object): def subsetsWithDup(self, nums): """ :type nums: List[int] :rtype: List[List[int]] ...

2018-05-29 11:11:23 159

原创 LeetCode---64. Minimum Path Sum

题目给出一个m * n的网格,网格里面的数字是非负数。找出一条从[0, 0]到[m -1, n - 1]的路径,使得路径上元素的和最小。注意:你每次只能向右和向下走一步。如:Example:Input: [ [1,3,1], [1,5,1], [4,2,1] ] Output: 7 Explanation: Because the path 1→3→1→1→1...

2018-05-29 10:47:20 167

原创 LeetCode---56. Merge Intervals

题目给出一个间隔的数组,合并所有重叠的间隔。如: Example 1:Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]]Example 2:Input: [[1,4],[4,5]] Output: [[1,5]]Python题解class Solution(object): ...

2018-05-29 10:24:31 143

原创 LeetCode---40. Combination Sum II

题目给出一个数组和目标值,找出所有的组合,使得组合里面元素的和为目标值。注意:原数组可能有重复元素;数组中的元素在组合里只能出现一次。如:Example 1:Input: candidates = [10,1,2,7,6,1,5], target = 8, A solution set is: [ [1, 7], [1, 2, 5], [2, 6], [1,...

2018-05-29 10:07:31 126

原创 LeetCode---39. Combination Sum

题目给出一个数组,没有重复元素,另给出一个目标值,找出所有的组合,组合的和为目标值。注意:相同的元素可以重复无限次。Python题解class Solution(object): def combinationSum(self, candidates, target): """ :type candidates: List[int] ...

2018-05-28 16:31:08 115

原创 LeetCode---33. Search in Rotated Sorted Array

题目给出一个递增有序数组,以某个元素为准旋转,如[0,1,2,4,5,6,7]变成了[4,5,6,7,0,1,2]。另给出一个目标值,在这个数组中寻找,如果找到返回index,否则返回-1。数组中没有重复元素,你的算法时间复杂度必须为O(logn)。Python题解class Solution(object): def search(self, nums, target):...

2018-05-28 16:11:48 138

原创 LeetCode---229. Majority Element II

题目给出一个整数数组,找出所有超过n / 3次的数。算法时间复杂度必须是O(n),空间复杂度为O(1)。Python题解class Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: List[int] ...

2018-05-28 15:52:35 164

原创 LeetCode---556. Next Greater Element III

题目给出一个32bit的正整数n,你需要找到一个这样的数,这个数和原来的数含有相同的数字,但是新数是比原数大的最小的数。如果不存在就放回-1。如:Example 1:Input: 12 Output: 21Example 2:Input: 21 Output: -1Python题解class Solution: def nextGreaterElemen...

2018-05-28 14:57:24 284

原创 LeetCode---31. Next Permutation

题目给出一个序列,按照字典序重新安排序列元素的顺序,使得新的序列是下一个比原来序列大。如果不存在,就将序列逆序。Python题解class Solution(object): def nextPermutation(self, nums): """ :type nums: List[int] :rtype: void Do...

2018-05-28 14:42:41 164

原创 LeetCode----18. 4Sum

题目给出一个数组和一个目标值,找出4个元素,使得它们的和为目标值。找出所有满足该条件的四元组。Python题解class Solution: def fourSum(self,nums, target): """ :type nums: List[int] :type target: int :rtype:...

2018-05-28 11:55:20 153

原创 LeetCode---16. 3Sum Closest

题目给出一个数组和一个目标值,找出三个数,使得其和和目标值最接近。假设数组中只有一个结果满足该条件。Python题解class Solution(object): def threeSumClosest(self, nums, target): """ :type nums: List[int] :type target: i...

2018-05-28 11:44:04 142

原创 LeetCode---15. 3Sum

题目给定一个数组,找出3个元素a,b,c使得它们的和为0。找出所有符合该条件的三元组。Python题解class Solution: def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ n...

2018-05-28 11:11:44 220

原创 Java使用wait和notify实现生产者和消费者

1. 使用注意事项永远在synchronized的函数或对象里使用wait、notify和notifyAll,不然Java虚拟机会生成IllegalMonitorStateException。永远在while循环里而不是if语句下使用wait。这样,循环会在线程睡眠前后都检查wait的条件,并在条件实际上并未改变的情况下处理唤醒通知。永远在多线程间共享的对象上使用wait。notify...

2018-05-25 18:09:00 7261

原创 Git分支模型和开发规范

1.分支管理1.1 总览从上图可以看到主要包含下面几个分支:master: 主分支,主要用来版本发布。 develop:日常开发分支,该分支正常保存了开发的最新代码。 feature:从develop分支fork,合并回develop。具体的功能开发分支。 release:从develop分支fork,合并回develop和master。一般用于发布正式版本之前(即合并到...

2018-05-23 10:22:45 4468

原创 Java基础---String的==与equals比较

1.一道题目给出以下代码,请回答出输出内容是什么。String s1 = "Hello";String s2 = "Hello";String s3 = new String(("Hello"));char[] chs = {'H', 'e', 'l', 'l', 'o'};System.out.println(s1 == s2);//trueSystem.out.println..

2018-05-18 09:53:40 146

原创 Python模块datetime使用指南

0. 引入模块import datetime1. 获取当前时间now = datetime.datetime.now()print(now)2. 和字符串的相互转换s = now.strftime("%Y-%m-%d %H:%M:%S")print(s)s = now.strftime("%Y-%m-%d")print(s)date = datetime.da...

2018-05-15 19:49:36 292

原创 PyMySQL使用指南

0. 引用P有MySQLimport mysql1. 创建connection和cursor对象connection = pymysql.connect(host='localhost', user='username', password='passwd', ...

2018-05-14 12:03:26 847

原创 二叉搜索树转换成双向链表

题目给出一个二叉搜索树,将其转换成双向链表。Python题解class Solution(object): def __init__(self): self.last_node_in_list = None def convertBinaryTreeToDoubleList(self, root): if root is None: ...

2018-05-09 10:00:40 385

原创 LeetCode---437. Path Sum III

题目给出一个二叉树和一个目标值值,找到所有的路径,该路径上的节点数值和为目标值。路径不一定非要用根节点开始。举个例子:root = [10,5,-3,3,2,null,11,3,-2,null,1], sum = 8 10 / \ 5 -3 / \ \ 3 2 11 / \ \ 3 -2 1Retur...

2018-05-07 16:57:22 133

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除