DP 设计模式
策略模式
class MallardDuck extends Duck { |
识别应用中变化的方面,把它们和不变的方面分开。
针对接口编程,而不是针对实现编程。
// Implement |
优先使用组合而不是继承。
summary
策略模式定义了算法族并分别封装。策略让算法变化独立于使用它的客户。
class MallardDuck extends Duck { |
识别应用中变化的方面,把它们和不变的方面分开。
针对接口编程,而不是针对实现编程。
// Implement |
优先使用组合而不是继承。
策略模式定义了算法族并分别封装。策略让算法变化独立于使用它的客户。
<dependency> |
可以用Spring Initializr或Spirng CLI来构建项目
spring init -list # 列出参数 |
$ tree basic-project/ |
distributionUrl=https://maven.aliyun.com/repository/central/org/apache/maven/apache-maven/(edition.number)/apache-maven-(edition.number)-bin.zip |
mvn spring-boot:run |
“When in doubt go to the library.” – J.K.Rowling
Article1: What Are You Going to Do With That?
William Deresiewicz(《国家》杂志撰稿人和《新共和》杂志编辑)在斯坦福大学的演讲
The question my title poses, of course, is the one that is classically aimed at humanities majors. What practical value could there possibly be in studying literature or art or philosophy? So you must be wondering why I’m bothering to raise it here, at Stanford, this renowned citadel of science and technology. What doubt can there be that the world will offer you many opportunities to use your degree?
(学习文学、艺术或哲学能有什么用呢?所以你肯定纳闷,我为什么在在以科技堡垒而闻名的斯坦福提出这个问题呢?在大学学位给人带来众多机会的问题上还有什么可怀疑的吗?)
But that’s not the question I’m asking. By “do” I don’t mean a job, and by “that” I don’t mean your major. We are more than our jobs, and education is more than a major. Education is more than college, more even than the totality of your formal schooling, from kindergarten through graduate school. By “What are you going to do,” I mean, what kind of life are you going to lead? And by “that,” I mean everything in your training, formal and informal, that has brought you to be sitting here today, and everything you’re going to be doing for the rest of the time that you’re in school.
(但那不是我提出的问题。这里的“做”并不是指工作,“那”并不是指你的专业。我们不仅仅是要个工作,教育不仅仅是学一门专业。教育也不仅仅是上大学,甚至也不仅是从幼儿园到研究生院的正规学校教育。我说的“你要做什么”的意思是你要过什么样的生活?我所说的“那”指的是你得到的正规或非正规的任何训练, 那些把你送到这里来的东西,你在学校的剩余时间里将要做的任何事。)
排序每一个单词,就知道是不是异位词。
从数组中,找到nums[i] + nums[j] == target
,并返回{ i, j }
。
思路是双重循环,遍历每一个元素,求和是否为target。
然而,双重循环需要O(N2)的复杂度。因此,可以使用一张表,使用containsKey
方法识别是否存在当前i的target - nums[i]
,即可减少一重循环。
用Map高效率查找,减少一重循环。
从乱序数组中,找到最长连续(数组中不一定连续)的序列。要求O(N)。
首先用数组的值存入哈希表,然后遍历数组,判断map.constains(curNum++)
。
然而,即使这样还是效率不够高。
优化
!contains(curNum - 1)
判断是否为序列开始值去重;不处理中间值
标题 | 标题 | 标题 |
---|---|---|
左对齐 | 两端对齐 | 右对齐 |
Delete Line
Blod
Italic
Code
E=MC2
Link
[1]Hello, World!
public static void main(String[] args) { |
--- auto_detect: ture |
No Silver Bullet
By Brooks
[!NOTE]
Note that it is a note.
[!WARNING]
WARNING!
[!DANGER]
Notice the DANGER!
[!SUCCESS]
Now it is SUCCESS.
[!INFO]
Here is some INFO.
primary 提示块标签
Hello World! ↩︎
from pyecharts.charts import Bar |
Before starting the topic let me introduce myself. I am a Mobile Developer currently working in Warsaw and spending my free time for interview preparations. I started to prepare for interviews two years ago. At that time I should say I could not solve the two sum problem. Easy problems seemed to me like hard ones so most of the time I had to look at editorials and discuss section. Currently, I have solved ~800 problems and time to time participate in contests. I usually solve 3 problems in a contest and sometimes 4 problems. Ok, lets come back to the topic.
Recently I have concentrated my attention on Dynamic Programming cause its one of the hardest topics in an interview prep. After solving ~140 problems in DP I have noticed that there are few patterns that can be found in different problems. So I did a research on that and find the following topics. I will not give complete ways how to solve problems but these patterns may be helpful in solving DP.
hexo new "postName" # 新建文章 |
# Home page setting |
把你挑选的背景图片命名为:background.jpg,放在blog\themes\next\source\images里,在blog\themes\next\source\css_custom文件的custom.styl首部添加
body { |
# Windows,有些文件需要文件名相同才能打开 |
cd hexo-site |
cd hexo-site |
# 设置英文字体 |
npm install hexo-cli -g |
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
$ hexo new "My New Post" |
More info: Writing
$ hexo server |
More info: Server
$ hexo generate |
More info: Generating
$ hexo deploy |
More info: Deployment
# 需要管理员权限 |
mysql -u <username> -p |
-- 设置中文字符集 |
-- 创建数据库 |
-- 建表 |