- 博客(7)
- 收藏
- 关注
原创 设计模式学习 -- 单例模式
文章目录一、定义二、实现1. 饿汉模式2. 懒汉模式(线程不安全)3. 懒汉模式(线程安全)4. 双重检查模式(DCL)5. 静态内部类6. 枚举单例三、参考一、定义单例模式(Singleton Pattern),属于创建型模式。该模式确保一个类只有一个实例,并提供一个全局访问点。使用单例模式的情况下,在内存中只有一个实例,减小了内存的开销。同时,对于频繁使用的重量级对象,省略了创建对象的时...
2019-12-07 15:06:58
132
原创 LeetCode -- 279. Perfect Squares(完美平方)
文章目录一、原文二、翻译三、分析3.1 BFS3.2 DP四、AC代码4.1 BFS代码4.2 DP代码一、原文Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.Example 1:Input: ...
2019-05-08 16:03:04
195
原创 LeetCode -- 207. Course Schedule(课程计划)
文章目录一、原文二、翻译三、分析3.1 利用拓扑排序3.2 DFS四、AC代码4.1 利用拓扑排序4.2 DFS一、原文There are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0...
2019-04-30 10:58:18
136
原创 LeetCode -- 130. Surrounded Regions(周边区域)
文章目录一、原文二、翻译三、分析四、AC代码4.1. 代码14.2. 代码2一、原文Given a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’.A region is captured by flipping all 'O’s into 'X’s in that ...
2019-04-26 23:08:17
175
原创 LeetCode -- 108. Convert Sorted Array to Binary Search Tree(将有序数组转换为二叉搜索树)
文章目录一、原文二、翻译三、分析四、AC代码一、原文Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tr...
2019-04-15 19:41:00
136
原创 LeetCode -- 53. Maximum Subarray(最大子数组)
文章目录1. 原文2. 翻译3. 分析3.1. 普通法3.2. 动态规划法(DP)3.3. 分治递归(divide and conquer approach)4. AC代码4.1. 普通法4.2. DP4.3. 分治递归1. 原文Given an integer array nums, find the contiguous subarray (containing at least one...
2019-04-11 15:58:35
221
原创 LeetCode -- 31. Next Permutation(下一个排列)
文章目录原文原文Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest...
2019-04-10 22:55:30
141
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人