
算法
文章平均质量分 75
Sdtin
这个作者很懒,什么都没留下…
展开
-
8皇后问题
代码如下:import java.util.ArrayList;public class EightQueue { /** * 由于每行必有一个皇后,所以在dfs时,只考虑,将这个行的皇后放到列的哪个位置;否则会出现重复现象 */ private static ArrayList ylist,pointlist1,pointlist2; private static int原创 2017-06-19 19:12:29 · 275 阅读 · 0 评论 -
对平衡二叉树的增加和删除
import java.util.ArrayList;import java.util.Scanner;public class LearnAVL { private static ArrayList queue; public static void main(String[] args) { // TODO 自动生成的方法存根 queue=new ArrayList();原创 2017-07-01 21:45:23 · 439 阅读 · 0 评论 -
630. Course Schedule III
题目:There are n different online courses numbered from 1 to n. Each course has some duration(course length) t and closed on dth day. A course should be taken continuously for t days and must原创 2017-07-09 21:43:59 · 374 阅读 · 0 评论 -
629. K Inverse Pairs Array
题目:Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs.We define an inverse pair as following: For ith and原创 2017-07-09 21:13:12 · 356 阅读 · 0 评论 -
KMP算法
KMP算法通常用来匹配字符串,时间复杂度为O(n+m)。一般来说,我们匹配字符串,首先想到的是对源字符的每个位置,都进行匹配。但这样花费的时间过多,时间复杂度为O(n*m),虽然在实际中,也可以接近O(n+m)。KMP算法采用了一个数组来保存元素的位置,这样就可减少匹配的次数(是不是和DP有些类似呢)下面我们来说一下,它的实现思路,假设,有两个字符串源字符串R,目标字符串T,用来保存T中每个元原创 2017-08-01 21:39:51 · 406 阅读 · 0 评论