- 博客(20)
- 收藏
- 关注
原创 CMAKE_OBJC_COMPILER not found
解决这个问题的一个办法是显式的指定Objective C和Objective C++编译器:cmake -DCMAKE_OBJC_COMPILER=/usr/bin/clang -DCMAKE_OBJCXX_COMPILER=/usr/bin/clang++ ....
2020-12-28 10:56:57 242
原创 怎样让自己更聪明
我每过一段时间都会google一下此类话题,仿佛心灵鸡汤,偶尔能给我自己些许激励。我把容易操作的总结成条目。‘为什么’、‘怎么做‘就不解释了,应该都是显而易见的。适时的切换任务。不同的事情锻炼的是大脑不同的部位,适时的切换让大脑各个区域都得到锻炼。 科学的管理时间,如给自己一段无手机、无网络的空白时间。 每天阅读。 总结学过的东西,比如记笔记。 做益智游戏 经常做体育运动 吃健脑食品 冥想其中4、6、8也无数次的出现在各种励志、情绪管理、压力管理的视频和文章中。...
2020-12-27 20:03:23 148
原创 chaos monkey spring-boot
前些日子公司要求关键性服务达到99.95% 可用性。然而高可用性很大程度上取决于你所依赖的服务,如果你依赖的服务只能做到99.95%,而你对服务的依赖处理的不好,那么即使你服务本身没有任何问题,最多也只能做到99.95的可用性;如果你依赖了N个服务,那你的可用性就是99.95的N次方。所以这个时候都要尽量做到即使你依赖的出了问题,你也可以用一些缓存或者降级的方法来尽可能的处理用户请求,而不至于完全无法响应。我们这方面的做了很多考虑,但是一直没有全面的测试过我们依赖的服务真的出了问题,我们的方法会不会很
2020-12-26 23:38:42 297
原创 最简paxos协议
paxos协议是一种分布式协议,它的目的是在多个参与者中达成一致。这个一致性遵循的是少数服从多数原则。paxos协议有三个角色:proposer, acceptor, learner。prososer提出建议,acceptor采纳建议,learner通过查询acceptor来得知最后的决定。一个paxos协议的运行过程是这样的:1. proposer向每个acceptor提出prepar...
2018-12-31 00:37:59 263
原创 serverless computing
Software engineer radio有一段关于serverless computing的访谈,听后觉得还是有很多新奇的地方,记下几点:Function As a service其实是构建在Container As a service的基础上的。FAAS没有什么奇特的地方,你部署一段函数到FAAS,FAAS启动一个container,准备好函数运行的环境(比如nodejs, pytho...
2018-12-30 19:50:07 451
原创 [leetcode] LRU Cache
public class LRUCache {static class DoubleLinkedNode { private int value, key; private DoubleLinkedNode previous, next; private DoubleLinkedNode(int key, int value) { this.key = key
2014-10-31 13:14:57 357
原创 [leetcode] Find Minimum in Rotated Sorted Array
public int findMin(int[] num) {int l = 0, h = num.length-1, m;while(l num[h]){l = m+1;}else //num[m]<num[h]{h = m;}}return num[l]; }
2014-10-29 21:37:51 270
原创 [leetcode] Find Minimum in Rotated Sorted Array II
public int findMin(int[] num) {int l = 0, h = num.length-1, m;while(l = num[h]){l = m+1;}else //num[m]<num[h]{h = m;}}return num[l]; }
2014-10-29 21:34:33 295
原创 [leetcode] Maximum Product Subarray
public int maxProduct(int[] A, int start, int end) { int product = 1; int leftProduct = 1; for(int i = start; i { product *= A[i]; }
2014-10-29 21:30:18 266
原创 [leetcode] Binary Tree Postorder Traversal
public List postorderTraversal(TreeNode root) {List r = new ArrayList(); TreeNode p = new TreeNode(0);//Dummy TreeNode c = root; Stack st = new Stack(); while(c!= null || !st.isEmpty()) { if(c != null
2014-10-15 12:27:04 262
原创 [leetcode] Binary Tree Preorder Traversal
public List preorderTraversal(TreeNode root) { List result = new ArrayList(); Stack st = new Stack(); TreeNode current = root; while(current != null || !st.isEmpty()) { if(current != null)
2014-09-16 17:48:40 235
原创 [leetcode] Reorder List
public void reorderList(ListNode head) { if(head == null || head.next == null) return; ListNode fast, slow, pre = null; slow = fast = head; while(fast != null && fast.next != null) { p
2014-09-15 13:49:25 341
原创 [leetcode] Linked List Cycle II
public ListNode detectCycle(ListNode head){ ListNode slow, fast; slow = fast = head; while(slow != null && slow.next != null && fast != null && fast.next != null) { slow
2014-09-15 12:40:31 254
原创 [leetcode] Linked List Cycle
public boolean hasCycle(ListNode head) { ListNode slow, fast; slow = fast = head; while(slow != null && fast != null && fast.next != null) { slow = slow.next; fast = fast.next.next; if(slow
2014-09-15 12:34:54 247
原创 [leetcode] work break II
public class Solution { public List wordBreak(String s, Set dict) { boolean breakable[] = new boolean[s.length()+1]; breakable[0] = true; for(int i = 1; i <= s.length(); i+
2014-09-15 12:29:22 385
原创 [leetcode] Copy List with Random Pointer, Java
public RandomListNode copyRandomList(RandomListNode head) { if(head == null) return null; RandomListNode p = head; while(p != null) { RandomListNode tmp = new RandomLi
2014-09-11 12:53:26 278
原创 [leetcode] Single Number II
public int singleNumber(int[] A) { int bitsNum = 32; int [][] bits = new int[bitsNum][2]; for(int i = 0; i < A.length; i++) { for(int j = 0; j < bitsNum; j++) { bits[j][((A[i]&(1<<j
2014-09-11 12:34:14 276
原创 [leetcode] Candy Java
public int candy(int [] ratings){assert(ratings != null && ratings.length > 0);int children[] = new int[ratings.length];children[0] = 1;for(int i = 1; i < ratings.length; i++){children[i] = ratings[i-
2014-09-11 12:18:12 285
原创 [leetcode] Gas Station java
public int canCompleteCircuit(int[] gas, int[] cost) { int sum = 0; int total = 0; int lastPoint = 0; for(int i = 0; i < gas.length; i ++) { sum += gas
2014-09-09 13:04:23 318
原创 [leetcode] word break, java
public boolean wordBreak(String s, Set dict) {boolean breakable[] = new boolean[s.length()+1];breakable[0] = true;for(int i = 1; i {for(int j = 0; j {if(breakable[j] && dict.contains
2014-09-09 12:47:40 289
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人