随笔分类 - Linkedin
摘要:what if the list doesn't contains the result?
阅读全文
摘要:Write a program that takes an integer and prints out all ways to multiply smaller integers that equal the original number, without repeating sets of factors. In other words, if your output contains 4...
阅读全文
摘要:Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest" O...
阅读全文
摘要:Approach #2: Double Linked List + TreeMap [Accepted] Intuition Using structures like Array or Stack will never let us popMax quickly. We turn our atte
阅读全文
摘要:Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Input: 5 Output: True Explanation: 1 * 1 + 2 * 2 = 5 Example 2: Input: ...
阅读全文
摘要:array不是sorted的,里面可能有负数。解法也是从两边往中间搞,用两个数组left和right存原数组从左向右和从右向左的元素和。然后按index来比较left和right两个数组里的元素,有相等的就是balance point.
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings.第二遍做法:时间复杂度应该是O(m*n),m表示字符串的最大长度,n表示字符串的个数,空间复杂度应该是O(m),即字符串的长度 public class Solution { public String longest...
阅读全文
摘要:Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm
阅读全文
摘要:Given a tree string expression in balanced parenthesis format:[A[B[C][D]][E][F]].Construct a tree and return the root of the tree. A / | \ B E F / \ C
阅读全文
摘要:private static String convertBinary(int sum) { StringBuffer binary = new StringBuffer(); while (true) { binary.insert(0, sum % 2); sum = sum / 2...
阅读全文
摘要:we start from the leftmost point (or point with minimum x coordinate value) and we keep wrapping points in counterclockwise direction. The big questio
阅读全文
摘要:我就想了个递归, 还是没有区分掉一些重复的情况,worst case O(2^n)基本同暴力解 Map> allSubSet = new HashMap(); Set getAllPalidrome(String s, int x, int y){ int ind = x * s.length() + y; if(allSubSet.constainsKey(ind)) return a...
阅读全文
摘要:每次移动3个pointer 里面最小的那个就好了。记录整个过程找最近的3个数。3个数之中median没意义,距离主要由最小和最大决定。基本就是这个思路。很快编完就过了编程阶段。
阅读全文
摘要: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
阅读全文
摘要: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 ...
阅读全文
摘要: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[...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:第一道是设计一个有选择性的iterator,类型T。面试官给的API里有一个自定selector,selector里有差不多叫boolean isOK(T t)方法。设计一个iterator每次调用hasNext(),返回接下来是否能取到合格的T对象;每次调用next(),返回下一个合格的T对象。我
阅读全文

浙公网安备 33010602011771号