- 博客(203)
- 资源 (1)
- 收藏
- 关注

原创 Cracking the coding interview汇总目录
很久之前刷的CTCI的题目,都快忘记了,做个分类汇总,再重新好好复习一遍。Chapter 1 | Arrays and Strings1.1 Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data stru
2014-12-26 20:07:34
4039
原创 Android NDK 开发:CMake 使用
1. 前言当在做 Android NDK 开发时,如果不熟悉用 CMake 来构建,读不懂 CMakeLists.txt 的配置脚本,很容易就会踩坑,遇到编译失败,一个很小的配置问题都会浪费很多时间。所谓工欲善其事必先利其器,学习 NDK 开发还是要大致了解 CMake 的基本语法和配置的。下面文章是根据 CMake 实践手册 做的一些简短笔记,具体说得不够详细的地方,可以查看手册。2. CMake
2017-08-26 17:46:12
2247
原创 Android NDK 开发:实战案例
0. 前言如果只学理论,不做实践,不踩踩坑,一般很难发现真正实践项目中的问题的,也比较难以加深对技术的理解。所以延续上篇 JNI 的实战Android NDK开发:JNI实战篇 ,这篇主要是一些 NDK 小项目的练习,由于这些项目网上都有 demo介绍,这里不会具体一步步介绍如何操作,只记录一些个人需要注意的地方或一些主要步骤,详细的介绍或代码可以点击里面的链接查看。1. 文件加解密和分割合并1.1
2017-08-19 10:58:56
2277
原创 微信 Mars Android Sample 源码分析
注:原文首发地址零、前言Mars 是微信官方开源的跨平台跨业务的终端基础组件,具有高质量网络连接模块(长短连接、智能心跳机制)、高性能日志模块和网络监测组件等。而整个 Android Sample 是基于 Mars 开发的一个 demo,包含提供了以下功能:基于TCP长连接的聊天室体验。数据通信成功率、耗时、流量的展示。网络状况检测结果展示。一、本地运行 Server 端具体如何运行 Ser
2017-08-11 23:16:42
6375
原创 Android NDK开发:JNI实战篇
注:首发地址紧接上篇:Android NDK开发:JNI基础篇 | cfanr,这篇主要介绍 JNI Native 层调用Java 层的代码(涉及JNI 数据类型映射和描述符的使用)和如何动态注册 JNI。 1. Hello World NDK在开始实战练习前,你需要先大致了解运行一个 Hello World 的项目大概需要做什么,有哪些配置以及配置的具体意思。 Android Studio(2.2
2017-08-06 09:08:15
1495
原创 Android NDK开发:JNI基础篇
Android NDK开发:JNI基础篇JNI 概念1.1 概念JNI 全称 Java Native Interface,Java 本地化接口,可以通过 JNI 调用系统提供的 API。操作系统,无论是 Linux,Windows 还是 Mac OS,或者一些汇编语言写的底层硬件驱动都是 C/C++ 写的。Java和C/C++不同 ,它不会直接编译成平台机器码,而是编译成虚拟机可以运行的Java
2017-08-05 10:20:51
1896
原创 【Effective Java】创建和销毁对象
一、考虑用静态工厂方法代替构造器构造器是创建一个对象实例的最基本最常用的方法。开发者在使用某个类的时候,通常会使用new一个构造器来实现,其实也有其他方式可以实现的,如利用发射机制。这里主要说的是通过静态类工厂的方式来创建class的实例,如:public static Boolean valueOf(boolean b) { return b ? Boolean.T
2015-02-02 16:04:17
1544
原创 【LeetCode】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.For example:Given the below binary tree and sum = 22, 5 /
2014-12-24 17:20:13
1099
原创 【LeetCode】Sum Root to Leaf Numbers
题目Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find th
2014-12-23 15:27:19
1207
原创 【LeetCode】Same Tree
题目Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.解答
2014-12-21 16:31:06
1030
原创 【LeetCode】Binary Tree Inorder Traversal
题目Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].解答中序遍历二叉树。递归法
2014-12-21 15:00:21
1065
原创 【LeetCode】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.解答求树的最小深度。类似Maximum Depth
2014-12-20 15:36:45
1239
原创 【LeetCode】Maximum Depth of Binary Tree
题目Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.解答求二叉树的最大深度。递归:a.若二叉树为空,
2014-12-20 14:47:47
1358
原创 【LeetCode】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).For example:Given binary tree {3,9,20,#,#
2014-12-19 16:34:53
1033
原创 【LeetCode】Binary Tree Level Order Traversal
题目Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \
2014-12-19 16:04:05
1242
原创 【LeetCode】Symmetric Tree
题目Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3B
2014-12-18 15:38:36
1072
原创 【LeetCode】Balanced Binary Tree
题目Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node nev
2014-12-18 14:33:21
1378
转载 酒桌上的计算机网络
前言:很有趣,很有意思的一篇文章,找资料在别人博客上无意发现的,原文链接:http://raychase.iteye.com/blog/1388742酒宴开始。 酒杯盛酒,酒杯碰撞,这是物理层;你要根据不同人的外貌特征找到你要敬酒的人所坐的位置,这是IP协议(网络层);你明白,敬酒的实际目的是加深感情,这在应用层,而这酒中的感情,才是报文的数据部
2014-12-17 15:57:21
874
原创 【LeetCode】Combination Sum
题目Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimi
2014-12-17 15:38:18
1100
原创 【LeetCode】3Sum Closest
题目Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would ha
2014-12-14 16:14:59
1184
原创 【LeetCode】Two Sum
题目Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the tar
2014-12-13 15:06:24
1200
原创 【LeetCode】Convert Sorted List to Binary Search Tree
题目Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.解答题目要求将链表转化为二叉查找树。利用树的中序遍历的递归思想,对链表结点一个个进行访问,先对左子树进行递归,然后将当前结点作为根,迭代到下一个链表结点,最后在递
2014-12-12 18:53:56
1053
原创 【LeetCode】Reverse Nodes in k-Group
题目Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain
2014-12-12 18:27:47
1062
原创 【LeetCode】Merge k Sorted Lists
题目Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.解答方法1:利用分治的思想把合并k个链表分成两个合并k/2个链表的任务,一直划分,知道任务中只剩一个链表或者两个链表。可以很简单的用递归来实现。因此算法复杂度为T(k) = 2
2014-12-12 16:57:45
1051
原创 【LeetCode】Copy List with Random Pointer
题目A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.解答题目要求拷贝一个链表,该链表除了一个next
2014-12-12 15:20:04
916
原创 【LeetCode】Partition List
题目Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in
2014-12-11 17:00:59
1011
原创 【LeetCode】Linked List Cycle II
题目Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?解答利用快慢指针使用Linked List Cycle I的办法,判
2014-12-10 15:47:59
930
原创 【LeetCode】Swap Nodes in Pairs
题目Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant
2014-12-10 15:01:01
849
转载 面向GC的Java编程-coolshell
Java程序员在编码过程中通常不需要考虑内存问题,JVM经过高度优化的GC机制大部分情况下都能够很好地处理堆(Heap)的清理问题。以至于许多Java程序员认为,我只需要关心何时创建对象,而回收对象,就交给GC来做吧!甚至有人说,如果在编程过程中频繁考虑内存问题,是一种退化,这些事情应该交给编译器,交给虚拟机来解决。这话其实也没有太大问题,的确,大部分场景下关心内存、GC的问题,显得有点“
2014-12-10 10:35:25
732
原创 【LeetCode】Remove Duplicates from Sorted List II
题目Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Giv
2014-12-09 16:35:37
1109
原创 【LeetCode】Rotate List
题目Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.解答题目要求对链表循环右移k的位置,注意k可能会大
2014-12-09 15:39:37
1367
原创 【LeetCode】Reorder List
题目Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorde
2014-12-09 14:57:57
928
原创 【LeetCode】Reverse Linked List II
题目Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n sat
2014-12-08 16:57:33
993
原创 【LeetCode】Intersection of Two Linked Lists
题目Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘
2014-12-08 15:07:25
1681
原创 【LeetCode】Merge Two Sorted Lists
题目Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.解答注意假的头结点的运用,代码如下:/** * Definition for singly-
2014-12-06 16:36:21
1425
原创 【LeetCode】Remove Duplicates from Sorted List
题目Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.解答法1:从表头开始一个个比较
2014-12-06 16:00:37
1236
原创 【LeetCode】Remove Nth Node From End of List
题目Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the
2014-12-05 16:07:31
1304
原创 【LeetCode】Insert Interval
题目Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start tim
2014-12-05 15:26:05
1117
原创 【LeetCode】Merge Intervals
题目Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].解答先对间隔段按起点由小到大排序(起点相同按终点排),那么问题来了,如何对对象进行排
2014-12-05 14:52:20
1193
原创 Java的Comparator和Comparable对比
1.对象如何对比排序?Java的基本类型如int, float, double都可以直接使用java.util.Arrays.sort(Object[])对比排序,那对象是如何比较排序的呢?我们定义的类都是继承Object类的,Object类的equals的方法,默认是比较两个对象是否相等(hashcode相同)public boolean equals(Object obj) {
2014-12-04 20:53:22
1613
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人