classSolution{public:intcountTexts(stringpressedKeys){intm=1000000007;vectordp3={1,1,2,4};vectordp4={1,1,2,4};intn=pressedKeys.size();for(inti=4;i
Leetcode刷题笔记题解(C++):64. 最小路径和
Demo.demo
Leetcode算法题解leetcode笔记c++
思路一:dfs深度优先搜索,然后取最小路径值,但是时间消耗较大,时间复杂度可能不满足,代码如下:classSolution{public:intres=1000000;introws,cols;intminPathSum(vector>&grid){rows=grid.size();cols=grid[0].size();dfs(grid,0,0,0);returnres;}voiddfs(vec
【Linux】命令行解释器脚本编写
樊梓慕
Linuxlinux运维服务器
樊梓慕:个人主页个人专栏:《C语言》《数据结构》《蓝桥杯试题》《LeetCode刷题笔记》《实训项目》《C++》《Linux》《算法》每一个不曾起舞的日子,都是对生命的辜负目录前言1.简单了解命令行解释器2.为什么要手写一个命令行解释器?3.命令行解释器脚本编写3.1打印提示符3.2获取用户输入3.3解析用户输入(分割字符串)3.4创建子进程进行程序替换3.5内建命令的处理3.5.1什么是内建命令
Leetcode刷题笔记题解(C++):590. N 叉树的后序遍历
Demo.demo
Leetcode算法题解leetcode笔记c++
思路:类似于二叉树的排序,这里需要将子树进行依次递归遍历,前序遍历也与之类似/*//DefinitionforaNode.classNode{public:intval;vectorchildren;Node(){}Node(int_val){val=_val;}Node(int_val,vector_children){val=_val;children=_children;}};*/class
Leetcode刷题笔记题解(C++):257. 二叉树的所有路径
Demo.demo
Leetcode算法题解leetcode笔记c++
思路:深度优先搜索/***Definitionforabinarytreenode.*structTreeNode{*intval;*TreeNode*left;*TreeNode*right;*TreeNode():val(0),left(nullptr),right(nullptr){}*TreeNode(intx):val(x),left(nullptr),right(nullptr){}*
Leetcode刷题笔记题解(C++):45. 跳跃游戏 II
Demo.demo
Leetcode算法题解leetcode笔记c++
classSolution{public:intjump(vector&nums){intans=0;intstart=0;intend=1;while(end=nums.size())returnans+1;}start=end;end=maxpos+1;ans++;}returnans;}};
【Linux】文件周边002之初步理解文件管理(打开的文件)
樊梓慕
Linuxlinux运维服务器
樊梓慕:个人主页个人专栏:《C语言》《数据结构》《蓝桥杯试题》《LeetCode刷题笔记》《实训项目》《C++》《Linux》《算法》每一个不曾起舞的日子,都是对生命的辜负目录前言1.(打开的)文件管理2.重定向2.1dup2系统调用3.如何理解Linux下一切皆文件4.C语言中的FILE结构体4.1FILE中的文件描述符4.2FILE中的缓冲区前言本篇文章博主将会讲解『Linux系统是如何管理文
Leetcode刷题笔记题解(C++):200. 岛屿数量
Demo.demo
Leetcode算法题解leetcode笔记c++
思路:利用深度优先搜索的思路来查找1身边的1,并且遍历之后进行0替换防止重复dfs,代码如下所示classSolution{public:intnumIslands(vector>&grid){introw=grid.size();intcol=grid[0].size();intnumoflands=0;//从第一行开始遍历,是岛屿则进行周围深度优先搜索for(intr=0;r>&grid,in
Leetcode刷题笔记题解(C++):1863. 找出所有子集的异或总和再求和
Demo.demo
Leetcode算法题解leetcode笔记c++
思路如下:递归思路,依次遍历数组中的数,当前数要不要选择像二叉树一样去遍历如下图所示00(选5)5(不选5)0101060606060+6+1+7+5+3+4+2=28classSolution{public:intres=0;intn=0;intsubsetXORSum(vector&nums){n=nums.size();dfs(nums,0,0);returnres;}voiddfs(vec
Leetcode刷题笔记题解(C++):66. 加一
Demo.demo
Leetcode算法题解c++leetcode数据结构
思路:分为两种情况1.没有进位,直接+完就完,比如46+1=472.有进位而且还需要扩展一位,比如99+1=100代码如下:classSolution{public:vectorplusOne(vector&digits){intjinwei=1;for(inti=digits.size()-1;i>=0;i--){inttemp=digits[i];digits[i]=(temp+jinwei)
Leetcode刷题笔记题解(C++):6. Z 字形变换
Demo.demo
Leetcode算法题解字符串c++leetcode算法
思路:根据每个字符的下标来确定它在哪一行,然后生产新的字符串即可代码如下:classSolution{public:stringconvert(strings,intnumRows){intsize=s.length();//行数取定义行数,如果字符串的长度小于行数的话则取字符串长度numRows=min(numRows,size);//如果字符串的长度为1或者行数为1时,直接输出原字符串if(n
Leetcode刷题笔记题解(C++):18. 四数之和
Demo.demo
Leetcode算法题解c++算法leetcode数据结构
思路:在三数之和的基础上加一层循环即可,注意跳过相等的元素。代码如下,思路也可以看看我的注释:classSolution{public:vector>fourSum(vector&nums,inttarget){//先从小到大进行排序sort(nums.begin(),nums.end());//存放结果vector>result;//数组大小intsize=nums.size();//选择第一个
Leetcode刷题笔记题解(C++):LCR 016.无重复字符的最长子串
Demo.demo
Leetcode算法题解leetcode笔记c++
思路:利用滑动窗口的思想,用起始位置startindex和curlength来记录这个滑动窗口的大小,并且得出最长距离;利用哈希表来判断在滑动窗口中是否存在重复字符,代码如下所示:classSolution{public:intlengthOfLongestSubstring(strings){//如果为空字符串,则返回0if(s.length()==0)return0;intmaxlength=
Leetcode刷题笔记题解(C++):51. N皇后
Demo.demo
剪枝leetcodec++N皇后问题递归回溯
思路:递归回溯符合规则:左上方(斜),上方(列),右上方(斜)都没有放置Q从第一行找位置,在第一行中遍历找位置,如果符合要求则放置皇后进入到下一行或者不放皇后看下一个位置如果最后行数=要求的n,则得到结果,大概思路图:(4皇后为例)看图大概能看懂的吧,几乎把每一种结果都试了,最后行数=n的话则为结果,剪枝的条件是符合上面那个规则代码如下:classSolution{public:vector>so
Leetcode刷题笔记题解(C++):94. 二叉树的中序遍历
Demo.demo
Leetcode算法题解c++算法leetcode二叉树栈
思路:利用栈做辅助来写算法,具体流程可见下图:帮助理解classSolution{public:vectorinorderTraversal(TreeNode*root){vectorres;stacks;while(root||!s.empty()){if(root){s.push(root);root=root->left;}else{root=s.top();res.push_back(ro
Leetcode刷题笔记题解(C++):1306. 跳跃游戏 III
Demo.demo
Leetcode算法题解bfsc++leetcode数据结构算法
利用BFS的思路,注意标记已经走过的下标,还有两种跳跃的情况向前走或者向后走。代码如下:classSolution{public:boolcanReach(vector&arr,intstart){if(arr[start]==0)returntrue;queueq;vectorused(arr.size());q.push(start);used[start]=true;while(!q.emp
Leetcode刷题笔记题解(C++):141. 环形链表
Demo.demo
Leetcode算法题解c++leetcode链表回环
解决思路:常规做法就是利用辅助数据来记录遍历的节点,如果当前遍历的节点在辅助空间中存在即存在循环链表,否则没有存在循环链表。但是需要空间比较大。这里思路是用两个节点不同速度去遍历,一个走两步,一个走一步,在遍历不为空的情况下如果某次相遇则是回环链表。代码如下:/***Definitionforsingly-linkedlist.*structListNode{*intval;*ListNode*n
Leetcode刷题笔记题解(C++):739. 每日温度
Demo.demo
Leetcode算法题解c++栈算法leetcode
###解题思路:利用栈来解决。注意的是栈中压入的下标的值首先压入0如果栈不为空且要压入的下标值i有T[i]>T[栈顶元素]则res[栈顶元素]=i-栈顶元素否则继续压栈,直到压完T中所有的数据为止。还要注意的是,开始对res全部赋值为0,这就对栈中的元素没弹出来的默认为0;这里附一下图吧,好理解一点。代码如下:classSolution{public:vectordailyTemperatures
Leetcode刷题笔记题解(C++):36. 有效的数独
Demo.demo
Leetcode算法题解leetcode笔记c++
思路一:暴力破解,两个二维数组记录行、列对应的数字出现的次数,比如rows[i][index]表示的数字index在i行出现的次数,三维数组记录每个块中对应数字出现的次数,比如boxes[i/3][j/3][index]表示的数字index在[i/3][j/3]个块中出现的次数,然后进行判断可以得出结果,超过1则不符合代码如下:classSolution{public:boolisValidSud
Leetcode刷题笔记题解(C++):99. 恢复二叉搜索树
Demo.demo
Leetcode算法题解leetcode笔记c++
思路:二叉搜索树的中序遍历是递增序列,可以在中序遍历中记录两个需要交换的节点,直到遍历完毕之后,对两个节点的值进行交换即可得到正确的二叉搜索树比如中序序列为1237564(7比5大记录7为x,6比4大记录4为y,交换x与y)/***Definitionforabinarytreenode.*structTreeNode{*intval;*TreeNode*left;*TreeNode*right;
ztree设置禁用节点
3213213333332132
JavaScriptztreejsonsetDisabledNodeAjax
ztree设置禁用节点的时候注意,当使用ajax后台请求数据,必须要设置为同步获取数据,否者会获取不到节点对象,导致设置禁用没有效果。
$(function(){
showTree();
setDisabledNode();
});
JVM patch by Taobao
bookjovi
javaHotSpot
在网上无意中看到淘宝提交的hotspot patch,共四个,有意思,记录一下。
7050685:jsdbproc64.sh has a typo in the package name
7058036:FieldsAllocationStyle=2 does not work in 32-bit VM
7060619:C1 should respect inline and
将session存储到数据库中
dcj3sjt126com
sqlPHPsession
CREATE TABLE sessions (
id CHAR(32) NOT NULL,
data TEXT,
last_accessed TIMESTAMP NOT NULL,
PRIMARY KEY (id)
);
<?php
/**
* Created by PhpStorm.
* User: michaeldu
* Date
Vector
171815164
vector
public Vector<CartProduct> delCart(Vector<CartProduct> cart, String id) {
for (int i = 0; i < cart.size(); i++) {
if (cart.get(i).getId().equals(id)) {
cart.remove(i);
各连接池配置参数比较
g21121
连接池
排版真心费劲,大家凑合看下吧,见谅~
Druid
DBCP
C3P0
Proxool
数据库用户名称 Username Username User
数据库密码 Password Password Password
驱动名
[简单]mybatis insert语句添加动态字段
53873039oycg
mybatis
mysql数据库,id自增,配置如下:
<insert id="saveTestTb" useGeneratedKeys="true" keyProperty="id"
parameterType=&
struts2拦截器配置
云端月影
struts2拦截器
struts2拦截器interceptor的三种配置方法
方法1. 普通配置法
<struts>
<package name="struts2" extends="struts-default">
&
IE中页面不居中,火狐谷歌等正常
aijuans
IE中页面不居中
问题是首页在火狐、谷歌、所有IE中正常显示,列表页的页面在火狐谷歌中正常,在IE6、7、8中都不中,觉得可能那个地方设置的让IE系列都不认识,仔细查看后发现,列表页中没写HTML模板部分没有添加DTD定义,就是<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3
String,int,Integer,char 几个类型常见转换
antonyup_2006
htmlsql.net
如何将字串 String 转换成整数 int?
int i = Integer.valueOf(my_str).intValue();
int i=Integer.parseInt(str);
如何将字串 String 转换成Integer ?
Integer integer=Integer.valueOf(str);
如何将整数 int 转换成字串 String ?
1.
PL/SQL的游标类型
百合不是茶
显示游标(静态游标)隐式游标游标的更新和删除%rowtyperef游标(动态游标)
游标是oracle中的一个结果集,用于存放查询的结果;
PL/SQL中游标的声明;
1,声明游标
2,打开游标(默认是关闭的);
3,提取数据
4,关闭游标
注意的要点:游标必须声明在declare中,使用open打开游标,fetch取游标中的数据,close关闭游标
隐式游标:主要是对DML数据的操作隐
JUnit4中@AfterClass @BeforeClass @after @before的区别对比
bijian1013
JUnit4单元测试
一.基础知识
JUnit4使用Java5中的注解(annotation),以下是JUnit4常用的几个annotation: @Before:初始化方法 对于每一个测试方法都要执行一次(注意与BeforeClass区别,后者是对于所有方法执行一次)@After:释放资源 对于每一个测试方法都要执行一次(注意与AfterClass区别,后者是对于所有方法执行一次
精通Oracle10编程SQL(12)开发包
bijian1013
oracle数据库plsql
/*
*开发包
*包用于逻辑组合相关的PL/SQL类型(例如TABLE类型和RECORD类型)、PL/SQL项(例如游标和游标变量)和PL/SQL子程序(例如过程和函数)
*/
--包用于逻辑组合相关的PL/SQL类型、项和子程序,它由包规范和包体两部分组成
--建立包规范:包规范实际是包与应用程序之间的接口,它用于定义包的公用组件,包括常量、变量、游标、过程和函数等
--在包规
【EhCache二】ehcache.xml配置详解
bit1129
ehcache.xml
在ehcache官网上找了多次,终于找到ehcache.xml配置元素和属性的含义说明文档了,这个文档包含在ehcache.xml的注释中!
ehcache.xml : http://ehcache.org/ehcache.xml
ehcache.xsd : http://ehcache.org/ehcache.xsd
ehcache配置文件的根元素是ehcahe
ehcac
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderL
白糖_
javaeclipsespringtomcatWeb
今天学习spring+cxf的时候遇到一个问题:在web.xml中配置了spring的上下文监听器:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
随后启动
angular.element
boyitech
AngularJSAngularJS APIangular.element
angular.element
描述: 包裹着一部分DOM element或者是HTML字符串,把它作为一个jQuery元素来处理。(类似于jQuery的选择器啦) 如果jQuery被引入了,则angular.element就可以看作是jQuery选择器,选择的对象可以使用jQuery的函数;如果jQuery不可用,angular.e
java-给定两个已排序序列,找出共同的元素。
bylijinnan
java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CommonItemInTwoSortedArray {
/**
* 题目:给定两个已排序序列,找出共同的元素。
* 1.定义两个指针分别指向序列的开始。
* 如果指向的两个元素
sftp 异常,有遇到的吗?求解
Chen.H
javajcraftauthjschjschexception
com.jcraft.jsch.JSchException: Auth cancel
at com.jcraft.jsch.Session.connect(Session.java:460)
at com.jcraft.jsch.Session.connect(Session.java:154)
at cn.vivame.util.ftp.SftpServerAccess.connec
[生物智能与人工智能]神经元中的电化学结构代表什么?
comsci
人工智能
我这里做一个大胆的猜想,生物神经网络中的神经元中包含着一些化学和类似电路的结构,这些结构通常用来扮演类似我们在拓扑分析系统中的节点嵌入方程一样,使得我们的神经网络产生智能判断的能力,而这些嵌入到节点中的方程同时也扮演着"经验"的角色....
我们可以尝试一下...在某些神经
通过LAC和CID获取经纬度信息
dai_lm
laccid
方法1:
用浏览器打开http://www.minigps.net/cellsearch.html,然后输入lac和cid信息(mcc和mnc可以填0),如果数据正确就可以获得相应的经纬度
方法2:
发送HTTP请求到http://www.open-electronics.org/celltrack/cell.php?hex=0&lac=<lac>&cid=&
JAVA的困难分析
datamachine
java
前段时间转了一篇SQL的文章(http://datamachine.iteye.com/blog/1971896),文章不复杂,但思想深刻,就顺便思考了一下java的不足,当砖头丢出来,希望引点和田玉。
-----------------------------------------------------------------------------------------
小学5年级英语单词背诵第二课
dcj3sjt126com
englishword
money 钱
paper 纸
speak 讲,说
tell 告诉
remember 记得,想起
knock 敲,击,打
question 问题
number 数字,号码
learn 学会,学习
street 街道
carry 搬运,携带
send 发送,邮寄,发射
must 必须
light 灯,光线,轻的
front
linux下面没有tree命令
dcj3sjt126com
linux
centos p安装
yum -y install tree
mac os安装
brew install tree
首先来看tree的用法
tree 中文解释:tree
功能说明:以树状图列出目录的内容。
语 法:tree [-aACdDfFgilnNpqstux][-I <范本样式>][-P <范本样式
Map迭代方式,Map迭代,Map循环
蕃薯耀
Map循环Map迭代Map迭代方式
Map迭代方式,Map迭代,Map循环
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
蕃薯耀 2015年
Spring Cache注解+Redis
hanqunfeng
spring
Spring3.1 Cache注解
依赖jar包:
<!-- redis -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
Guava中针对集合的 filter和过滤功能
jackyrong
filter
在guava库中,自带了过滤器(filter)的功能,可以用来对collection 进行过滤,先看例子:
@Test
public void whenFilterWithIterables_thenFiltered() {
List<String> names = Lists.newArrayList("John"
学习编程那点事
lampcy
编程androidPHPhtml5
一年前的夏天,我还在纠结要不要改行,要不要去学php?能学到真本事吗?改行能成功吗?太多的问题,我终于不顾一切,下定决心,辞去了工作,来到传说中的帝都。老师给的乘车方式还算有效,很顺利的就到了学校,赶巧了,正好学校搬到了新校区。先安顿了下来,过了个轻松的周末,第一次到帝都,逛逛吧!
接下来的周一,是我噩梦的开始,学习内容对我这个零基础的人来说,除了勉强完成老师布置的作业外,我已经没有时间和精力去
架构师之流处理---------bytebuffer的mark,limit和flip
nannan408
ByteBuffer
1.前言。
如题,limit其实就是可以读取的字节长度的意思,flip是清空的意思,mark是标记的意思 。
2.例子.
例子代码:
String str = "helloWorld";
ByteBuffer buff = ByteBuffer.wrap(str.getBytes());
Sy
org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1, column 1
Everyday都不同
$转义el表达式
最近在做Highcharts的过程中,在写js时,出现了以下异常:
严重: Servlet.service() for servlet jsp threw exception
org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1,
用Java实现发送邮件到163
tntxia
java实现
/*
在java版经常看到有人问如何用javamail发送邮件?如何接收邮件?如何访问多个文件夹等。问题零散,而历史的回复早已经淹没在问题的海洋之中。
本人之前所做过一个java项目,其中包含有WebMail功能,当初为用java实现而对javamail摸索了一段时间,总算有点收获。看到论坛中的经常有此方面的问题,因此把我的一些经验帖出来,希望对大家有些帮助。
此篇仅介绍用
探索实体类存在的真正意义
java小叶檀
POJO
一. 实体类简述
实体类其实就是俗称的POJO,这种类一般不实现特殊框架下的接口,在程序中仅作为数据容器用来持久化存储数据用的
POJO(Plain Old Java Objects)简单的Java对象
它的一般格式就是
public class A{
private String id;
public Str