- 博客(708)
- 收藏
- 关注
转载 Android Binder机制和用例
Android 系统是基于 Linux 内核的,Linux 已经提供了管道、消息队列、共享内存和 Socket 等 IPC 机制。那为什么 Android 还要提供 Binder 来实现 IPC 呢?主要是基于性能、稳定性和安全性几方面的原因。这里我们先从 Linux 中进程间通信涉及的一些基本概念开始介绍,然后逐步展开,向大家说明传统的进程间通信的原理。进程隔离进程空间划分:用户空间(User Space)/内核空间(Kernel Space)系统调用:用户态/内核态。
2022-10-17 11:14:42
594
原创 Leetcode 213. 打家劫舍 II
你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金。这个地方所有的房屋都围成一圈,这意味着第一个房屋和最后一个房屋是紧挨着的。同时,相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。给定一个代表每个房屋存放金额的非负整数数组,计算你在不触动警报装置的情况下,能够偷窃到的最高金额。class Solution {public: ...
2020-03-29 21:46:19
334
转载 mysql double write
转自:https://www.cnblogs.com/cchust/p/3961260.htmlmysql double write (二次写)是mysql innodb存储引擎的一个重要特性,本人这两天翻阅了相关的资料,结合自己已有的知识,说说自己对double write的理解,供各位看官参考。页断裂(partial write)double write技术innodb为解决...
2020-01-10 16:40:57
448
转载 Java8内存模型—永久代(PermGen)和元空间(Metaspace)
转自https://ww一、JVM 内存模型 根据 JVM 规范,JVM 内存共分为虚拟机栈、堆、方法区、程序计数器、本地方法栈五个部分。 1、虚拟机栈:每个线程有一个私有的栈,随着线程的创建而创建。栈里面存着的是一种叫“栈帧”的东西,每个方法会创建一个栈帧,栈帧中存放了局部变量表(基本数据类型和对象引用)、操作数栈、方法出口等信息。栈的大小可以固定也可以动态扩展。当栈调用深...
2019-03-23 16:18:09
280
原创 leetcode: 560. Subarray Sum Equals K DescriptionHintsSubmissionsDiscussSolution Given an array of in
560. Subarray Sum Equals KDescriptionHintsSubmissionsDiscussSolutionPick OneGiven an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equal...
2018-10-12 00:05:36
263
原创 leetcode 147. Insertion Sort List
Sort a linked list using insertion sort.A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.With each iteration one element...
2018-10-10 00:01:54
204
原创 leetcode 103. Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tre...
2018-09-16 14:59:22
182
原创 leetcode 102. 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,null,null,15,7], 3 / \ 9 20 ...
2018-09-16 14:15:08
194
原创 leetcode: 316. Remove Duplicate Letters
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order a...
2018-09-16 08:03:13
271
原创 leetcode 228. Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges.Example 1:Input: [0,1,2,4,5,7]Output: ["0->2","4->5","7"]Explanation: 0,1,2 form a continuous range; 4,5...
2018-09-10 19:26:09
180
原创 leetcode: 334. Increasing Triplet Subsequence
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there exists i, j, k such that arr[i] < arr[...
2018-09-09 23:08:39
177
转载 hbase的行锁与多版本并发控制(MVCC)
http://san-yun.iteye.com/blog/2156663参考:http://www.rigongyizu.com/hbase-row-lock-and-multiversion-concurrency-control/ MVCC (Multiversion Concurrency Control),即多版本并发控制技术,它使得大部分支持行锁的事务引擎,不再单纯的使用行...
2018-09-08 17:11:49
700
原创 leetcode:Palindromic Substrings
Given a string, your task is to count how many palindromic substrings in this string.The substrings with different start indexes or end indexes are counted as different substrings even they consist ...
2018-08-13 07:31:30
192
原创 leetcode 279. Perfect Squares
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.Example 1:Input: n = 12Output: 3 Explanation: 12 = 4 + 4 + 4.Example...
2018-08-12 18:51:27
188
原创 leetcode: 115. Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleting some (ca...
2018-08-12 08:05:12
183
原创 leetcode:813. Largest Sum of Averages(DP)
We partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve?Note that our partition m...
2018-08-11 14:58:37
225
原创 leetcode 129. 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 the tota...
2018-08-08 00:18:48
182
原创 [leetcode] 116 Populating Next Right Pointers in Each Node
iven a binary treestruct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next;}Populate each next pointer to point to its next right node. If there is no next right ...
2018-08-07 23:49:39
186
转载 Java 并发 --- 非阻塞队列之ConcurrentLinkedQueue源码分析
转自:https://blog.youkuaiyun.com/u014634338/article/details/78825440在并发编程中,有时候需要使用线程安全的队列,如果要实现一个线程安全的队列有两种方式:一种是使用阻塞算法,另一种是使用非阻塞算法,在前面我们逐一分析过阻塞队列,这篇文章过后,会写篇关于阻塞队列的总结,也算是回顾知识,非阻塞的实现方式则可以使用循环cas的方式来实现,对于循环cas的...
2018-05-20 17:57:02
429
转载 Spark创建DataFrame的三种方法
转自:https://vimsky.com/article/2708.html跟关系数据库的表(Table)一样,DataFrame是Spark中对带模式(schema)行列数据的抽象。DateFrame广泛应用于使用SQL处理大数据的各种场景。创建DataFrame有很多种方法,比如从本地List创建、从RDD创建或者从源数据创建,下面简要介绍创建DataFrame的三种方法。方法一,Spark...
2018-03-29 20:27:22
47873
2
转载 深夜学算法之SkipList:让链表飞
转自:https://www.jianshu.com/p/fcd18946994e1. 前言上次写Python操作LevelDB时提到过,有机会要实现下SkipList。摘录下wiki介绍:跳跃列表是一种随机化数据结构,基于并联的链表,其效率可比拟二叉查找树。我们知道对于有序链表,查找的时间复杂度为O(n),尽管真正的插入与删除操作节点复杂度只有O(1),但都需要先查找到节点的位置,可以说是查找拉...
2018-03-29 13:49:58
274
原创 判断是否正确的出栈顺序
bool isOK(int *arr, int len) { stack<int> auxStack; int i = 0; // the index for the arr int j = 1; // the number in seq 1,2,3,4,5 while (j <= len + 1) { //这里是len + 1的原因是,当5入栈的时候j就变成了6,...
2018-02-27 15:11:20
472
转载 堆排序
http://blog.youkuaiyun.com/zdp072/article/details/44227317[算法说明]堆排序是对简单选择排序的改进简单选择排序是从n个记录中找出一个最小的记录,需要比较n-1次。但是这样的操作并没有把每一趟的比较结果保存下来,在后一趟的比较中,有许多比较在前一趟已经做过了,但由于前一趟排序时未保存这些比较结果,所以后一趟排序时又重复
2017-11-22 01:18:11
229
转载 理解TIME_WAIT
转自 www.firefoxbug.com/index.php/archives/2795/前言TIME_WAIT 是在TCP协议中很模糊的概念,它可能使socke能陷入的一种时间相对比较长的状态,过多的TIME_WAIT会影响新socket的建立。TIME_WAIT为什么会存在?它的作用又是什么?下面我们就来理解下TIME_WAIT。
2017-11-20 21:48:14
295
转载 N的结成
转自:http://blog.youkuaiyun.com/liyong199012/article/details/40341779题目:求100!这看起来是一个很简答的问题,递归解之毫无压力[java] view plain copyint func(int n){ if(n 1) return 1;
2017-11-06 15:34:42
363
转载 POJ 1019 Number Sequence【数论】
转自 http://www.cnblogs.com/Hilda/archive/2012/08/17/2644739.htmlDescriptionA single positive integer i is given. Write a program to find the digit located in the position i in the sequenc
2017-10-27 10:20:49
302
原创 lintcode: Count of Smaller Number
Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 10000) and an query list. For each query, give you an integer, return the number of element in the ar
2017-07-03 23:17:02
410
原创 lintcode: Insert Delete GetRandom O(1)
Design a data structure that supports all following operations in average O(1)time.insert(val): Inserts an item val to the set if not already present.remove(val): Removes an item val from the se
2017-07-02 01:24:52
322
原创 lintcode: Dices Sum
Throw n dices, the sum of the dices' faces is S. Given n, find the all possible value of S along with its probability. NoticeYou do not care about the accuracy of the result, we will help yo
2017-07-02 00:11:32
385
原创 lintcode: Partition Equal Subset Sum
Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. NoticeEach of t
2017-06-30 00:47:45
354
原创 Perfect Squares
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.Have you met this question in a real interview? Yes
2017-06-29 23:34:23
267
原创 深度探索C++对象模型
根据这个图片我们可以看出,对于虚继承体系来说,任何一个对象的构造执行顺序总是从深到浅、从远到近,既最先构造的总是最底层的基类。 这样看起来似乎并没有什么值得奇怪的地方,但是让我们想想,如果我们把主函数main中的代码改成【Point3d p3d;】呢?相信按下F5后,会输出两句执行结果:【This is Point construct!】和【This is Point3d con
2016-11-06 14:06:12
392
转载 Miko Android自学之路 WifiDirect中文最强详解,如何传输数据,如何设置GroupOwener,如何设置客户端以及服务器端
转自http://blog.youkuaiyun.com/mikogodzd/article/details/50965178
2016-05-15 00:50:10
482
转载 lintcode:Minimum Adjustment Cost
Given an integer array, adjust each integers so that the difference of every adjacent integers are not greater than a given number target.If the array before adjustment is A, the array after adjustm
2016-04-06 19:47:00
508
原创 lintcode:Word Search II
Given a matrix of lower alphabets and a dictionary. Find all words in the dictionary that can be found in the matrix. A word can start from any position in the matrix and go left/right/up/down to th
2016-04-06 17:43:28
319
原创 lintcode:Copy Books
Given an array A of integer with size of n( means n books and number of pages of each book) and k people to copy the book. You must distribute the continuous id books to one people to copy. (You can g
2016-04-06 15:03:17
753
转载 leetcode:排序数组之后相邻数的最大差
https://leetcode.com/discuss/27754/my-c-code-12-ms-bucket-sort-o-n-time-and-spaceThe key is to use the fact that the lower bound of the gap is (maxV - minV )/ (sSize - 1). With such in min
2016-04-05 00:53:36
1271
原创 lintcode:Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.Have you met this question in a real interview?ExampleGiven n = 3, your program should
2016-04-03 22:19:56
321
原创 lintcode: Unique Binary Search Trees
Given n, how many structurally unique BSTs (binary search trees) that store values 1...n?Have you met this question in a real interview?ExampleGiven n = 3, there are a total of 5 uniqu
2016-04-03 21:51:24
597
原创 lintcode:Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinct numbers from the original list.Have you met this question in a real interview?ExampleGi
2016-04-03 21:04:50
270
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人