Specific topics in Part 2 include: greedy algorithms (scheduling, minimum spanning trees, clustering, Huffman codes), dynamic programming (knapsack, s ...
分类:
其他好文 时间:
2019-03-15 09:15:23
阅读次数:
287
#include<iostream> using namespace std; struct TreeNode{ int val; TreeNode* right; TreeNode* left; TreeNode(int _val):val(_val),right(nullptr),left(nu ...
分类:
其他好文 时间:
2019-03-14 16:49:22
阅读次数:
190
思路很好理解的。双下标,第一个固定,然后第二个在之后不断移动,如果比第一个下标指定的值大的话,就相减。 设一个temp等于差值,与上一次的maxpro进行比较,如果大的话,maxpro等于temp。 python: python这里用函数很方便,在价格最低那天买入,价格最高那天卖出,就会获得最大利润 ...
分类:
编程语言 时间:
2019-03-14 13:19:42
阅读次数:
212
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l ...
分类:
其他好文 时间:
2019-03-10 09:16:10
阅读次数:
172
Spring框架的两个核心分别是 IOC(Inversion of Control)控制反转 和 AOP(Asepect-Oriented Programming)面向切面编程。 此外,有的书本上将写的是DI(Dependency Injection)依赖注入和AOP。实际上,DI和IOC的目标和方 ...
分类:
编程语言 时间:
2019-03-08 22:03:05
阅读次数:
169
题目如下: In an array A containing only 0s and 1s, a K-bit flip consists of choosing a (contiguous) subarray of length K and simultaneously changing every ...
分类:
其他好文 时间:
2019-03-05 15:32:36
阅读次数:
213
我在之前讲过0-1背包和完全背包,这里讲多重背包。不同于0-1背包和完全背包,多重背包中每个物品有个给定的数量。假定背包容量为m,有n个物品,每个物品的重量为weight[i], 价值为value[i], 数目为num[i]. 显然,多重背包可以转化为0-1背包问题:将num[i]个物品i看作是nu ...
分类:
其他好文 时间:
2019-03-05 09:43:24
阅读次数:
189
什么是IoC IoC是Inversion of Control的缩写,翻译过来为“控制反转”。简单来说,就是将对象的依赖关系交由第三方来控制。在理解这句话之前,我们先来回顾一下IoC的演化。 Ioc前世今生 传统的new class的方式 我们写了一个ChineseSpeaker的类,他有一个Say ...
分类:
其他好文 时间:
2019-03-04 19:20:54
阅读次数:
204
一、IOC(Inversion of Control)容器:就是具有依赖注入(Dependncy Injection)功能的容器,是可以创建对象的容器,IOC容器负责实例化、定位、配置应用程序中的对象及建立这些对象间的依赖。通常new一个实例,控制权由程序员控制,而"控制反转"是指new实例工作不由 ...
分类:
编程语言 时间:
2019-03-04 17:08:51
阅读次数:
198
There are N piles of stones arranged in a row. The i-th pile has stones[i] stones. A move consists of merging exactly K consecutive piles into one pil ...
分类:
其他好文 时间:
2019-03-04 09:25:03
阅读次数:
149