自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 Java NIO学习总结三(Selector)

上一篇讲了NIO的缓冲区,在给出的例子中当有多个SocketChannel连接到服务器时,我们是通过遍历各个Channel来管理它们的输入输出,其实也可以交给NIO的选择器来管理,下面给出使用Selector的同等效果的实现: public class SelectorTest { public static void main(String[] args) { tr

2015-12-30 17:06:49 416

原创 Java NIO学习总结二(Buffer缓冲区)

12123

2015-12-29 20:12:17 611

原创 Java NIO学习总结一(非阻塞特性)

NIO(New IO)是从Java 1.4版开始引入的新的IO API,其与标准的JAVA IO API的差异本质上体现在资源的利用方式上。可以从现实中餐厅排队的例子来理解这一点,饭点到了,某顾客选择了三家餐厅A、B、C吃饭,餐厅位置已满,以前传统APIf

2015-12-29 11:09:02 2749

原创 Java代码中调用shell脚本和python脚本并获得输出结果(分为小数据量和大数据量)

Java代码中调用shell和python脚本有多种实现方式,通用方式是使用java.lang中的Runtime类新开进程,调用python脚本的一个例子如下(shell同理): public String python(String pythonPath, String[] params) { File file = new File(pythonPath);

2015-12-23 13:31:00 4879 1

原创 Restore IP Addresses

题目: Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given "25525511135", return ["255.255.11.135", "255.255.111.35"]

2014-04-16 15:24:26 441

原创 Longest Repeated Sequence

题目:

2014-04-07 15:10:52 642

原创 Decode Ways

题目: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded message containing digits, determine the t

2014-04-07 14:44:42 435

原创 Minimum Depth of Binary Tree

题目: 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 leaf node.

2014-04-04 15:53:42 404

原创 Palindrome Partitioning

题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return

2014-04-04 12:44:51 557

原创 Path Sum II

题目:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. 算法思想:递归

2014-04-03 22:57:19 428

原创 Binary Tree Level Order Traversal II

题目:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). 算法思想: 1,首先想到的是递归,对于一个结点,将左子树和右子树返回的结果合并起来,再加上根结

2014-04-03 14:39:39 637

原创 Binary Tree Preorder Traversal(迭代写法)

题目:Given a binary tree, return the preorder traversal of its nodes' values. 算法思想:参见点击打开链接 vector preorderTraversal(TreeNode *root) { TreeNode *p = root; stack record; vector r

2014-04-02 22:30:33 888

原创 Binary Tree Postorder Traversal(迭代写法)

题目:Given a binary tree, return the postorder traversal of its nodes' values. 算法思想:迭代求一个二插树的后序遍历,首先得从根结点找到后序遍历输出的第一个结点(称“最左节点”),而且必须将这个过程中的所有结点记录下来(因为不能从儿子结点找到父结点),由于后入先出,所以选择栈记录,大体过程如下面步骤: 1.从根结点开

2014-04-02 22:08:51 593

原创 Palindrome Partitioning II

题目:Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab",

2014-04-01 14:49:48 422

原创 Max Points on a Line

题目:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 函数接口:int maxPoints(vector &points)  {} 算法思想:先剔除点数组points中重复的点,然后从前两个点开始,构建一条直线,依次加入新的点,新加入的

2014-03-30 20:58:10 352

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除