Thursday, February 28, 2019

759. Employee Free Time

759. Employee Free Time
Hard
We are given a list schedule of employees, which represents the working time for each employee.
Each employee has a list of non-overlapping Intervals, and these intervals are in sorted order.
Return the list of finite intervals representing common, positive-length free time for all employees, also in sorted order.
Example 1:
Input: schedule = [[[1,2],[5,6]],[[1,3]],[[4,10]]]
Output: [[3,4]]
Explanation:
There are a total of three employees, and all common
free time intervals would be [-inf, 1], [3, 4], [10, inf].
We discard any intervals that contain inf as they aren't finite.
Example 2:
Input: schedule = [[[1,3],[6,7]],[[2,4]],[[2,5],[9,12]]]
Output: [[5,6],[7,9]]
(Even though we are representing Intervals in the form [x, y], the objects inside are Intervals, not lists or arrays. For example, schedule[0][0].start = 1, schedule[0][0].end = 2, and schedule[0][0][0] is not defined.)
Also, we wouldn't include intervals like [5, 5] in our answer, as they have zero length.
Note:
  1. schedule and schedule[i] are lists with lengths in range [1, 50].
  2. 0 <= schedule[i].start < schedule[i].end <= 10^8.
----------------------
不用想太复杂
把所有的interval都插入到priorityQueue,然后找gap。题目中给的多少个人其实没有什么意义
O(n), n为总的interval数量
/**
 * Definition for an interval.
 * public class Interval {
 *     int start;
 *     int end;
 *     Interval() { start = 0; end = 0; }
 *     Interval(int s, int e) { start = s; end = e; }
 * }
 */
class Solution {
    public List<Interval> employeeFreeTime(List<List<Interval>> schedule) {
        PriorityQueue<Interval> que = new PriorityQueue<>((a, b) -> a.start - b.start);
        
        for (List<Interval> list : schedule) {
            for (Interval i : list) {
                que.add(i);
            }
        }
        
        List<Interval> rt = new ArrayList<>();
        int max = -1;
        while (!que.isEmpty()) {
            Interval top = que.poll();
            if (max != -1 && top.start > max) {
                rt.add(new Interval(max, top.start));
            }
            max = Math.max(max, top.end);
        }
        
        return rt;
    }
}

Wednesday, February 27, 2019

829. Consecutive Numbers Sum

829. Consecutive Numbers Sum
Hard
Given a positive integer N, how many ways can we write it as a sum of consecutive positive integers?
Example 1:
Input: 5
Output: 2
Explanation: 5 = 5 = 2 + 3
Example 2:
Input: 9
Output: 3
Explanation: 9 = 9 = 4 + 5 = 2 + 3 + 4
Example 3:
Input: 15
Output: 4
Explanation: 15 = 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5
Note: 1 <= N <= 10 ^ 9.
---------------------
求等差数列为1,和为N的数列的个数,假设数列的首项为x,项数是m,则如果存在这一数列,N = (x + (x + m - 1)) * m / 2. 那么我们就遍历m的可能性

O(lgN)
ref: https://zhanghuimeng.github.io/post/leetcode-829-consecutive-numbers-sum/
class Solution {
    public int consecutiveNumbersSum(int N) {
        int rt = 0;
        
        for (int m = 1; ; m++) {
            int mx = N - (m - 1) * m / 2;
            if (mx <= 0) break;
            if (mx % m == 0) rt++;
        }
        
        return rt;
    }
}

542. 01 Matrix

542. 01 Matrix
Medium
Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.
The distance between two adjacent cells is 1.
Example 1: 
Input:
0 0 0
0 1 0
0 0 0
Output:
0 0 0
0 1 0
0 0 0
Example 2: 
Input:
0 0 0
0 1 0
1 1 1
Output:
0 0 0
0 1 0
1 2 1
Note:
  1. The number of elements of the given matrix will not exceed 10,000.
  2. There are at least one 0 in the given matrix.
  3. The cells are adjacent in only four directions: up, down, left and right.
---------------------
Solution #1
BFS, 把所有的0放入queue中,用额外数组记录visited情况
O(m*n) time and space
class Solution {
    public int[][] updateMatrix(int[][] matrix) {
        int m = matrix.length, n = matrix[0].length;
        int[][] rt = new int[m][n];
        boolean[][] visited = new boolean[m][n];
        Queue<int[]> que = new LinkedList<>();
        
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (matrix[i][j] == 0) que.add(new int[]{i,j});
            }
        }
        
        int dis = 0;
        while (!que.isEmpty()) {
            for (int size = que.size(); size > 0; size--) {
                int[] top = que.poll();
                int r = top[0], c = top[1];
                
                if (r < 0 || r >= m || c < 0 || c >= n || visited[r][c]) continue;
                visited[r][c] = true;
                rt[r][c] = dis;
                que.add(new int[]{r - 1, c});
                que.add(new int[]{r + 1, c});
                que.add(new int[]{r, c + 1});
                que.add(new int[]{r, c - 1});
            }
            
            dis++;
        }
        
        return rt;
    }
}

Solution #2, DP,每个点有上下左右4个方向可以选择,如果符合条件,选每个方向路径都增加1。那我们先从matrix左上走到右下,再右下到左上。这样4个方向全部检查过
跟#1一样的复杂度
ref: https://leetcode.com/problems/01-matrix/discuss/101039/Java-33ms-solution-with-two-sweeps-in-O(n)

255. Verify Preorder Sequence in Binary Search Tree

255. Verify Preorder Sequence in Binary Search Tree
Medium
Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree.
You may assume each number in the sequence is unique.
Consider the following binary search tree: 
     5
    / \
   2   6
  / \
 1   3
Example 1:
Input: [5,2,6,1,3]
Output: false
Example 2:
Input: [5,2,1,3,6]
Output: true
Follow up:
Could you do it using only constant space complexity?
Accepted
32,826
Submissions
76,719
Seen this question in a real interview before?
-----------------------
Solution #1, O(n) time and space
stack里保证的是递增(从top到底下),遇到比top大说明是走到了右子树,然后把之前左子树跟root全部pop掉,取root为lower bound(之后再也不会遇到比这更小,如果有,说明顺序有错误)
这方法是模拟preorder traversal的iterative的版本

class Solution {
    public boolean verifyPreorder(int[] preorder) {
        Stack<Integer> st = new Stack<>();
        int low = Integer.MIN_VALUE;
        for (int i : preorder) {
            if (i < low) return false;
            
            while (!st.isEmpty() && st.peek() < i) {
                low = st.pop();
            }
            st.push(i);
        }
        
        return true;
    }
    
}

Solution #2 O(n) time, O(1) space, 把给定的preorder数组利用起来,当作stack来存

934. Shortest Bridge

934Shortest Bridge
In a given 2D binary array A, there are two islands.  (An island is a 4-directionally connected group of 1s not connected to any other 1s.)
Now, we may change 0s to 1s so as to connect the two islands together to form 1 island.
Return the smallest number of 0s that must be flipped.  (It is guaranteed that the answer is at least 1.)

Example 1:
Input: [[0,1],[1,0]]
Output: 1
Example 2:
Input: [[0,1,0],[0,0,0],[0,0,1]]
Output: 2
Example 3:
Input: [[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]]
Output: 1

Note:
  1. 1 <= A.length = A[0].length <= 100
  2. A[i][j] == 0 or A[i][j] == 1
-------------------
BFS
先标记出一个岛,然后做BFS直到碰到另一个岛
注意dis的初始值是 -1
class Solution {
    public int shortestBridge(int[][] arr) {

        Queue<int[]> que = new LinkedList<>();

        for (int i = 0; i < arr.length; i++) {
            boolean f = false;
            for (int j = 0; j < arr[0].length; j++) {
                if (arr[i][j] == 1) {
                    dfs(arr, i, j, que);
                    f = true;
                    break;
                }
            }
            if (f) break;
        }

        int dis = -1;
        while (!que.isEmpty()) {
            
            for (int size = que.size(); size > 0; size--) {
                int[] top = que.poll();
                int i = top[0], j = top[1];
                if (i < 0 || j < 0 || i >= arr.length || j >= arr[0].length || arr[i][j] == 3) continue;
                if (arr[i][j] == 1) return dis;
                arr[i][j] = 3;
                que.add(new int[]{i + 1, j});
                que.add(new int[]{i, j + 1});
                que.add(new int[]{i - 1, j});
                que.add(new int[]{i, j - 1});
            }
            dis++;
        }


        return 0;
    }

    private void dfs(int[][] arr, int i, int j, Queue<int[]> que) {
        if (i < 0 || j < 0 || i >= arr.length || j >= arr[0].length || arr[i][j] == 0 || arr[i][j] == 2) return;

        arr[i][j] = 2;
        que.add(new int[]{i, j});
        dfs(arr, i + 1, j, que);
        dfs(arr, i - 1, j, que);
        dfs(arr, i, j + 1, que);
        dfs(arr, i, j - 1, que);
    }
}

Sunday, February 24, 2019

640. Solve the Equation

640Solve the Equation
Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable x and its coefficient.
If there is no solution for the equation, return "No solution".
If there are infinite solutions for the equation, return "Infinite solutions".
If there is exactly one solution for the equation, we ensure that the value of x is an integer.
Example 1:
Input: "x+5-3+x=6+x-2"
Output: "x=2"
Example 2:
Input: "x=x"
Output: "Infinite solutions"
Example 3:
Input: "2x=x"
Output: "x=0"
Example 4:
Input: "2x+3x-6x=x+2"
Output: "x=-1"
Example 5:
Input: "x=x+2"
Output: "No solution"
--------------------
解一元一次方程。难点在处理string parsing上。计算左右2边常数项和变量各自的差,sign表示等号左右
class Solution {
    public String solveEquation(String equation) {
        int i = 0, start = 0, cof = 0, cos = 0, sign = 1;
        
        for (; i < equation.length(); i++) {
            if (equation.charAt(i) == '+' || equation.charAt(i) == '-') {
                if (i > start) cos += sign * Integer.parseInt(equation.substring(start,i));
                start = i;
            }else if (equation.charAt(i) == 'x') {
                if (i == start || equation.charAt(i - 1) == '+') {
                    cof += sign;
                }else if (equation.charAt(i - 1) == '-') {
                    cof -= sign;
                }else {
                    cof += sign * Integer.parseInt(equation.substring(start,i));
                }
                
                start = i + 1;
            }else if (equation.charAt(i) == '=') {
                if (i > start) cos += sign * Integer.parseInt(equation.substring(start,i));
                sign = -1;
                start = i + 1;
            }
        }
        
        if (start < equation.length()) cos += sign * Integer.parseInt(equation.substring(start));
        if (cof == 0 && cos == 0) return "Infinite solutions";
        if (cof == 0) return "No solution";
        return "x=" + Integer.toString(- cos / cof);
    }
}

361. Bomb Enemy

361Bomb Enemy
Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb.
The bomb kills all the enemies in the same row and column from the planted point until it hits the wall since the wall is too strong to be destroyed.
Note: You can only put the bomb at an empty cell.
Example:
Input: [["0","E","0","0"],["E","0","W","E"],["0","E","0","0"]]
Output: 3 
Explanation: For the given grid,

0 E 0 0 
E 0 W E 
0 E 0 0

Placing a bomb at (1,1) kills 3 enemies.
-------------------------
很直接的遍历。row里存的是当前横向杀人的敌人个数,cols[j]存的是在col j杀伤的敌人个数
只有在前一位是'W'的时候,才会检查杀伤到多少敌人

O(m * n) time, O(n) space
class Solution {
    public int maxKilledEnemies(char[][] grid) {
        if (grid.length == 0) return 0;
        int max = 0;
        int row = 0;
        int[] cols = new int[grid[0].length];
        
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid[0].length; j++) {
                if (grid[i][j] == 'W') continue;
                if (j == 0 || grid[i][j - 1] == 'W') {
                    row = getRow(grid, i, j);
                }
                
                if (i == 0 || grid[i - 1][j] == 'W') {
                    cols[j] = getCol(grid, i, j);
                }
                
                if (grid[i][j] == '0' && row + cols[j] > max) {
                    max = row + cols[j];
                }
            }
        }
        
        return max;
    }
    
    private int getRow(char[][] grid, int i, int j) {
        int rt = 0;
        while (j < grid[0].length && grid[i][j] != 'W') {
            if (grid[i][j] == 'E') rt++;
            j++;
        }
        
        return rt;
    }
    
    private int getCol(char[][] grid, int i, int j) {
        int rt = 0;
        while (i < grid.length && grid[i][j] != 'W') {
            if (grid[i][j] == 'E') rt++;
            i++;
        }
        
        return rt;
    }
}

353. Design Snake Game

353Design Snake Game
Design a Snake game that is played on a device with screen size = width x heightPlay the game online if you are not familiar with the game.
The snake is initially positioned at the top left corner (0,0) with length = 1 unit.
You are given a list of food's positions in row-column order. When a snake eats the food, its length and the game's score both increase by 1.
Each food appears one by one on the screen. For example, the second food will not appear until the first food was eaten by the snake.
When a food does appear on the screen, it is guaranteed that it will not appear on a block occupied by the snake.
Example:
Given width = 3, height = 2, and food = [[1,2],[0,1]].

Snake snake = new Snake(width, height, food);

Initially the snake appears at position (0,0) and the food at (1,2).

|S| | |
| | |F|

snake.move("R"); -> Returns 0

| |S| |
| | |F|

snake.move("D"); -> Returns 0

| | | |
| |S|F|

snake.move("R"); -> Returns 1 (Snake eats the first food and right after that, the second food appears at (0,1) )

| |F| |
| |S|S|

snake.move("U"); -> Returns 1

| |F|S|
| | |S|

snake.move("L"); -> Returns 2 (Snake eats the second food)

| |S|S|
| | |S|

snake.move("U"); -> Returns -1 (Game over because snake collides with border)
-----------------------
用Deque
注意点:要额外用一个set来存蛇身,用O(1)检测是否会撞到本身
head要额外复制一个数组
class SnakeGame {

    private Deque<int[]> snake;
    private Set<Integer> set; 
    private int score;
    private int width;
    private int height;
    private int[][] food;
    /** Initialize your data structure here.
        @param width - screen width
        @param height - screen height 
        @param food - A list of food positions
        E.g food = [[1,1], [1,0]] means the first food is positioned at [1,1], the second is at [1,0]. */
    public SnakeGame(int width, int height, int[][] food) {
        this.width = width;
        this.height = height;
        this.food = food;
        snake = new LinkedList<>();
        set = new HashSet<>();
        score = 0;
        snake.addFirst(new int[]{0,0});
        set.add(0);
    }
    
    /** Moves the snake.
        @param direction - 'U' = Up, 'L' = Left, 'R' = Right, 'D' = Down 
        @return The game's score after the move. Return -1 if game over. 
        Game over when snake crosses the screen boundary or bites its body. */
    public int move(String direction) {
        if (score == -1) return -1;

        int[] head = new int[]{snake.peekFirst()[0],snake.peekFirst()[1]};
        int[] tail = snake.pollLast();
        
        set.remove(tail[0] * width + tail[1]);
        
        if (direction.equals("U")) {
            head[0]--;
        }else if (direction.equals("L")) {
            head[1]--; 
        }else if (direction.equals("R")) {
            head[1]++;
        }else if (direction.equals("D")) {
            head[0]++;
        }

        if (head[0] < 0 || head[0] >= height || head[1] < 0 || head[1] >= width 
            || set.contains(head[0] * width + head[1])) {
            
            score = -1;
            return -1;
        }
        
        snake.addFirst(head);
        set.add(head[0] * width + head[1]);
        
        if (score < food.length && food[score][0] == head[0] && food[score][1] == head[1]) {
            score++;
            snake.addLast(tail);
            set.add(tail[0] * width + tail[1]);
        }
        
        return score;
    }
        
}

/**
 * Your SnakeGame object will be instantiated and called as such:
 * SnakeGame obj = new SnakeGame(width, height, food);
 * int param_1 = obj.move(direction);
 */

780. Reaching Points

780Reaching Points
A move consists of taking a point (x, y) and transforming it to either (x, x+y) or (x+y, y).
Given a starting point (sx, sy) and a target point (tx, ty), return True if and only if a sequence of moves exists to transform the point (sx, sy) to (tx, ty). Otherwise, return False.
Examples:
Input: sx = 1, sy = 1, tx = 3, ty = 5
Output: True
Explanation:
One series of moves that transforms the starting point to the target is:
(1, 1) -> (1, 2)
(1, 2) -> (3, 2)
(3, 2) -> (3, 5)

Input: sx = 1, sy = 1, tx = 2, ty = 2
Output: False

Input: sx = 1, sy = 1, tx = 1, ty = 1
Output: True

Note:
  • sx, sy, tx, ty will all be integers in the range [1, 10^9].
---------------
Solution #1, 因为给定的都是正数,所有可以对比tx跟ty,大的减去小的就是之前的那一对数
class Solution {
    public boolean reachingPoints(int sx, int sy, int tx, int ty) {
        while (tx >= sx && ty >= sy) {
            if (tx == sx && ty == sy) return true;
            if (tx > ty) {
                tx -= ty;
            }else {
                ty -= tx;
            }
        }
        
        return false;
    }
}

Solution #2, 跟#1类似,但是我们需要快速收敛。考虑以下例子
2, 12
2, 8
2, 6
2, 4
2, 2
class Solution {
    public boolean reachingPoints(int sx, int sy, int tx, int ty) {
        while (tx >= sx && ty >= sy) {
            if (tx == sx && ty == sy) return true;
            if (tx > ty) {
                if (ty == sy) return (tx - sx) % ty == 0;
                tx %= ty;
            }else {
                if (tx == sx) return (ty - sy) % tx == 0;
                ty %= tx;
            }
        }
        
        return false;
    }
}

Wednesday, February 20, 2019

392. Is Subsequence

392Is Subsequence
Given a string s and a string t, check if s is subsequence of t.
You may assume that there is only lower case English letters in both s and tt is potentially a very long (length ~= 500,000) string, and sis a short string (<=100).
A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ace" is a subsequence of "abcde" while "aec" is not).
Example 1:
s = "abc"t = "ahbgdc"
Return true.
Example 2:
s = "axc"t = "ahbgdc"
Return false.
Follow up:
If there are lots of incoming S, say S1, S2, ... , Sk where k >= 1B, and you want to check one by one to see if T has its subsequence. In this scenario, how would you change your code?
------------------
没啥好说的
class Solution {
    public boolean isSubsequence(String s, String t) {
        int i = 0, j = 0;
        
        while (i < s.length() && j < t.length()) {
            char c1 = s.charAt(i);
            char c2 = t.charAt(j);
            
            if (c1 != c2) j++;
            else {
                i++;
                j++;
            }
        }
        
        return i == s.length();
    }
}

Monday, February 18, 2019

583. Delete Operation for Two Strings

583Delete Operation for Two Strings
Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string.
Example 1:
Input: "sea", "eat"
Output: 2
Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
Note:
  1. The length of given words won't exceed 500.
  2. Characters in given words can only be lower-case letters.
--------------------
Solution #1
2个单词的长度和 -longest common subsequence * 2

class Solution {
    public int minDistance(String word1, String word2) {
        return word1.length() + word2.length() - 2 * lcs(word1,word2);
    }
    
    private int lcs(String s1, String s2) {
        int m = s1.length(), n = s2.length();
        int[][] dp = new int[m + 1][n + 1];
        
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (s1.charAt(i - 1) == s2.charAt(j - 1)) dp[i][j] = 1 + dp[i - 1][j - 1];
                else dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
        
        return dp[m][n];
    }
}

Solution #2 DP, ToDo
类似edit distance, 方程:
dp[x][y] = dp[x - 1][y - 1] if s1[x] == s2[y]
dp[x][y] = 1 + min(dp[x - 1][y], dp[x][y - 1) if s1[x] != s2[y]

Sunday, February 17, 2019

523. 560, Continuous Subarray Sum, Subarray Sum Equals K

523Continuous Subarray Sum
Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is, sums up to n*k where n is also an integer.
Example 1:
Input: [23, 2, 4, 6, 7],  k=6
Output: True
Explanation: Because [2, 4] is a continuous subarray of size 2 and sums up to 6.
Example 2:
Input: [23, 2, 6, 4, 7],  k=6
Output: True
Explanation: Because [23, 2, 6, 4, 7] is an continuous subarray of size 5 and sums up to 42.
Note:
  1. The length of the array won't exceed 10,000.
  2. You may assume the sum of all the numbers is in the range of a signed 32-bit integer.
-----------------
(sum - preSum) % k = 0
=>
sum % k = preSum % k

所以set里面要存的是sum % k,
class Solution {
    public boolean checkSubarraySum(int[] nums, int k) {
        if (nums == null || nums.length < 2) return false; 
        if (checkZeros(nums)) return true;
        if (k == 0) return false;
        
        int sum = nums[0];
        Set<Integer> set = new HashSet<>();
        set.add(0);
        set.add(sum);
        
        for (int i = 1; i < nums.length; i++) {
            sum += nums[i];
            sum %= k;
            if (set.contains(sum)) {
                return true;
            }
            set.add(sum);
        }
        
        return false;
    }
    
    private boolean checkZeros(int[] nums) {
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] == 0 && nums[i - 1] == 0) return true;
        }
        
        return false;
    }
}


560Subarray Sum Equals K
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.
Example 1:
Input:nums = [1,1,1], k = 2
Output: 2
Note:
  1. The length of the array is in range [1, 20,000].
  2. The range of numbers in the array is [-1000, 1000] and the range of the integer k is [-1e7, 1e7].
---------------
class Solution {
    public int subarraySum(int[] nums, int k) {
        Map<Integer, Integer> map = new HashMap<>();
        map.put(0,1);
        int sum = 0;
        int rt = 0;
        
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
            if (map.containsKey(sum - k)) rt += map.get(sum - k);
            map.put(sum, map.getOrDefault(sum, 0) + 1);
        }
        
        return rt;
    }
}

Saturday, February 16, 2019

Pure Storage


画圆经典题。followup: 如果像素点较少怎么办。
利口六六一
-------------------

https://www.1point3acres.com/bbs/thread-475566-1-1.html


小印面试官全程冷冰冰,没有交流,感觉开始就要fail我的样子

if (n%2 == 0) n = n/2

else n = 3*n + 1

3 --> 10 --> 5 ---> 16 ---> 8 ---> 4 ---> 2 ----> 1

总共需要7步

写一个函数计算步数,系统可能要call 几百万,所以需要计算这个步数更快



关于第二题 既然bottleneck在速度 我目前只能想到


(1) 不要recursively 要iteratively 因为arithmetic ops太cheap了 much lower than recursion overhead.


(2) For even number, simply use shifting ops 因为移位是底层arch实现里几乎最简单的操作了 比加法还快 while (x&1) { x = x>>1; ans++; } arch pipeline移动一步就可以做一个iteration了 没什么继续加速的必要了


(3) For odd number, simply use x + (x<<1) + 1, 两个加法和一个移位,也是底层arch里最简单的操作之一 结合(2)(3) 应该是快得要飞起来了 pipeline走几步就做完一组了


(4) 要考虑一下是不是一定有解 这个数学上证明一下就好 很简单的反证法 如果我碰到这题 肯定会主动证明这个结论


(5) 要是可以数学上估计出step的upper bound就更完美了 我没想出来



--------------------

https://www.1point3acres.com/bbs/thread-298316-1-1.html


valid square 给平面上四个点,判断是否能组成一个正方形。每个点是由(x,y)坐标表示。follow up是给n个点,问可以组成多少个valid square,要求先O(n^4),再改进到O(n^3),最后改进到 O(n^2)
event fire https://instant.1point3acres.com/thread/177053 https://www.evernote.com/shard/s260/sh/a01e5b26-d3eb-44c0-8ef4-01086605f675/da31dd196df57906d67ab4ea189304f1
bitmap http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=226030&extra=page%3D127%26filter%3Dsortid%26sortid%3D311%26sortid%3D311


http://www.1point3acres.com/bbs/thread-271461-1-1.html


画圆 可能需要用数学方法证明解法的正确性 http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=192327&extra=page%3D43%26filter%3Dsortid%26sortid%3D311%26sortid%3D311 https://www.cs.uic.edu/~jbell/CourseNotes/ComputerGraphics/Circles.html
implement O(1) set https://instant.1point3acres.com/thread/177053
image smooth 这篇帖子说要求in place http://www.1point3acres.com/bbs/thread-138406-1-1.html-baidu 1point3acres


另外一篇帖子里又说 in place 行不通 http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=202635&extra=page%3D5%26filter%3Dsortid%26sortid%3D311%26sortid%3D311


align rectangle/textbox http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=202635&extra=page%3D5%26filter%3Dsortid%26sortid%3D311%26sortid%3D311
c++ virtual table 相关知识 https://www.evernote.com/shard/s260/sh/dfc7453b-e50f-46c0-b223-196bead364a9/c41f1cea8f38c1802d1941338b03d375
call api http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=192290&extra=page%3D109%26filter%3Dsortid%26sortid%3D311%26sortid%3D311 http://www.1point3acres.com/bbs/thread-206999-1-1.html
sort color (3-way partition) 要求swap次数最少 http://www.1point3acres.com/bbs/thread-206999-1-1.html
which number can be represented as two decimal http://softwarecareerup.blogspot.com/2015/03/pure-storage-interview.html
implement lock http://softwarecareerup.blogspot.com/2015/03/pure-storage-interview.html
happy number LC 202 http://www.1point3acres.com/bbs/forum.php?mod=viewthread&tid=192327&extra=page%3D43%26filter%3Dsortid%26sortid%3D311%26sortid%3D311
memcpy, memmove http://www.1point3acres.com/bbs/thread-206999-1-1.html
fibonacci number both iterative and recursive http://www.1point3acres.com/bbs/thread-141925-1-1.html
coin change LC 322 http://www.1point3acres.com/bbs/thread-141925-1-1.html
min stack http://www.1point3acres.com/bbs/thread-141925-1-1.html
LRU cache, Skyline, Permutation, combination sum, roman to int
What data structure would you use to construct a skip list? Implement search() and insert(). http://www.cnblogs.com/binyue/p/4545555.html http://www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Map/skip-list-impl.html http://www.sanfoundry.com/java-program-implement-skip-list/
thread-safe stack 多线程下的stack的push和pop,好像只有校招会碰到。