上一页 1 2 3 4 5 6 7 8 ··· 28 下一页
摘要: 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 l 阅读全文
posted @ 2017-12-03 06:35 apanda009 阅读(122) 评论(0) 推荐(0) 编辑
摘要: code 不难,multi dimension array 的求 summation。 之前准备地里的LinkedIn高频题一个没碰到。。。 /** Suppose you are given a class that implements a k-dimensional array * interface and you want to perform an operation that ... 阅读全文
posted @ 2017-12-03 06:00 apanda009 阅读(380) 评论(0) 推荐(0) 编辑
摘要: public static int LPS(int[] a) { int[][] dp = new int[a.length][a.length]; for (int i = 0; i = 0; i--) { for (int j = i + 1; j < dp.length; j++) { if (a[i] == a[j]) { dp[i][j] = dp[... 阅读全文
posted @ 2017-12-03 04:07 apanda009 阅读(101) 评论(0) 推荐(0) 编辑
摘要: import java.util.*; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class BlockQueue { public int cap... 阅读全文
posted @ 2017-12-03 02:38 apanda009 阅读(176) 评论(0) 推荐(0) 编辑
摘要: import java.util.*; import java.util.concurrent.locks.*; public class H2O { private int HCount = 0; private int OCount = 0; private Lock lock = new ReentrantLock(); private Condition condH = lo... 阅读全文
posted @ 2017-12-03 02:37 apanda009 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 第一道是设计一个有选择性的iterator,类型T。面试官给的API里有一个自定selector,selector里有差不多叫boolean isOK(T t)方法。设计一个iterator每次调用hasNext(),返回接下来是否能取到合格的T对象;每次调用next(),返回下一个合格的T对象。我 阅读全文
posted @ 2017-12-03 02:20 apanda009 阅读(170) 评论(0) 推荐(0) 编辑
摘要: public class MidStack { static class Node{ T val; Node next = null; Node pre = null; public Node(T val){ this.val = val; } } private int size = 0; private Node head = null; privat... 阅读全文
posted @ 2017-12-03 01:53 apanda009 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 这道题要求in-place做法,不能使用extra space, 那么,做法跟Rotate Array那道题非常相似 (1)reverse the whole array (2)reverse each subarray seperated by ' ' 注意不要忘了reverse最后一个word 阅读全文
posted @ 2017-12-03 01:34 apanda009 阅读(133) 评论(0) 推荐(0) 编辑
摘要: /* Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and b... 阅读全文
posted @ 2017-12-03 01:25 apanda009 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 这题就是不停的DFS, 直到 n == 1. 有个判断条件 if (item.size() > 1) 是为了防止答案是自己本身n, 按照题意, 这是不允许的. 参考了:http://www.meetqun.com/thread-10673-1-1.html 时间复杂度, 个人觉得是O(n*log(n 阅读全文
posted @ 2017-12-02 22:43 apanda009 阅读(385) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 28 下一页